/* 
 * YTODO LO RELACIONADO CON METODOS DE Y PARA VALPAGPOS  ver 1.0.0
 */

/**
 *El poderoso meotodo valpagpos!
 **/
function valpag_pos(component, co_pagreg, co_pagina, linea, contenedor, id_frawor) {
    var va_pagreg = get_value_from_componente(component);//PARA CONSERVAR EL VALOR DEL COMPONENTE
    var js_o = $D.getJSON($D.base()+ "/" + "wfp?xact=1&co_pagreg=" + co_pagreg + "&va_pagreg=" + va_pagreg + "&co_pagina=" + co_pagina + "&contenedor=" + contenedor + "&id_frawor=" + id_frawor);//CONSEGUIR LA LISTA DE ITEM A CONTROLAR
    try {
        //alert("aqui"+js_o);
        //alert(js_o+":::id_valpag:"+js_o[0].id_valpag);
        //if(js_o[0].id_valpag != undefined){
        //alert(js_o+":::"+js_o[0].va_pagreg);
        var mi_L = get_value_from_componente_L(component);
        //alert(">>"+mi_L);
        //alert(js_o+":::"+js_o[0].va_pagreg);
        if (js_o != null) {
            //alert(js_o+":::"+js_o[0].co_pagreg);
            for (var i = 0; i < js_o.length; i++) {
                var valpag_a = new Valpag(js_o[i], null);
                //alert(">>"+valpag_a.getCo_pagreg()+"::");
                //alert("v"+co_pagina+"_"+linea+"_"+valpag_a.getCo_pagreg());
                var componente = $D.g_ID("v" + co_pagina + "_" + linea + "_" + valpag_a.getCo_pagreg());
                //alert("v"+co_pagina+"_"+linea+"_"+valpag_a.getCo_pagreg()+">>>"+componente);
                var valpag_de = new Valpag(null, componente);
                //alert(">"+valpag_de);
//                alert("{[" + valpag_de.getVa_pagreg() + "][" + valpag_de.getTx_pagreg() + "]");
                var uri = $D.base()+ "/" + "wfp?xact=2&co_pagreg=" + co_pagreg + "&va_pagreg=" + va_pagreg + "&co_regist=" + valpag_a.getCo_pagreg() + "&co_pagina=" + co_pagina + "&contenedor=" + contenedor + "&id_frawor=" + id_frawor;
                //alert("{2>>>de:"+valpag_de.getTi_pagreg()+" a:"+ valpag_a.getTi_pagreg()+"}");
                var xyh;

                //alert("evaluando:["+mi_L+"]:["+get_value_from_componente_L(componente)+"]");
                if (mi_L >= get_value_from_componente_L(componente)) {
                    //alert("3>>>de:"+valpag_de.getTi_pagreg()+" a:"+ valpag_a.getTi_pagreg());
                    if (valpag_de.getTi_pagreg() == valpag_a.getTi_pagreg()) {
//                        alert("componente igualson[valpag_de::"+valpag_de.toString()+"],[valpag_a::"+valpag_a.toString()+"]");
                        recarga_componente(valpag_de, valpag_a, componente.getAttribute("onchange"), uri);
                        //alert("recarga de datos ::"+valpag_de.getTi_pagreg());
                    } else {
                        //alert("componente diferente");
                        var f = "v" + co_pagina + "_" + linea + "_" + valpag_a.getCo_pagreg();

                        //alert("father send:"+mi_L);
                        //alert("father:["+$D.g_ID("va_regist_"+co_pagina+"_"+linea+"_"+valpag_de.getCo_pagreg())+"]:["+$D.g_ID("va_regist_"+co_pagina+"_"+linea+"_"+valpag_de.getCo_pagreg()).getAttribute("form")+"]["+f+"]");
                        xyh = actualiza_componente(valpag_de, valpag_a, componente.getAttribute("onchange"), uri, mi_L);
                        if (xyh) {
                            put_value_to_componente_L($D.g_ID("v" + co_pagina + "_" + linea + "_" + valpag_a.getCo_pagreg()));
                            $D.g_ID("v" + co_pagina + "_" + linea + "_" + valpag_a.getCo_pagreg()).onchange();
                            remove_value_to_componente_L($D.g_ID("v" + co_pagina + "_" + linea + "_" + valpag_a.getCo_pagreg()));
                        }
                    }
                } else {
                    xyh = remove_value_to_componente_L(componente);
                    if (xyh) {
                        put_value_to_componente_L($D.g_ID("v" + co_pagina + "_" + linea + "_" + valpag_a.getCo_pagreg()));
                        $D.g_ID("v" + co_pagina + "_" + linea + "_" + valpag_a.getCo_pagreg()).onchange();
                        remove_value_to_componente_L($D.g_ID("v" + co_pagina + "_" + linea + "_" + valpag_a.getCo_pagreg()));
                    }
                }
            }
        } else {
            mensaje(null, 'El juego de valores de [valpagpos] ha retornado nulo.', null, null, 3);
        }
    } catch (e) {
        e = e.toString();

        if (js_o.indexOf("[E]") != -1)
            e = js_o;
        else
            e = e.toString();

        if (e == "TypeError: js_o[0] is undefined" | e == "TypeError: Cannot read property 'id_valpag' of undefined") {
            mensaje('Error - Valpagpos(undefined)', e, null, null, 3);
        } else {
            mensaje('Error - Valpagpos', e, null, null, 3);
        }

    }
}

function actualiza_componente(de, a, onchange, url, L) {
    //            alert("ACTUALIZA_COMPONENTE----de["+de.getTi_pagreg()+":"+de.getTi_estreg()+":"+de.getId_valpag()+"] a["+a.getTi_pagreg()+":"+a.getTi_estreg()+":"+a.getId_valpag()+"]");
    //        alert("Elementos de de:\n "+de.toString());
    //        alert("Elementos de a:\n "+a.toString());
    var componente = $D.g_ID(de.getId_valpag());//componente a cambiar
    var $tr;
    try {
        $tr = componente.getParent();
        $tr = $tr.getParent();//Con esto se consigue el tr de dond ese ubican el titulo y el componente
    } catch (e) {
        $tr = componente.parentNode;
        $tr = $tr.parentNode;

    }

//    alert("de: "+de.getTi_pagreg() +" a: "+a.getTi_pagreg() );    
    if (de.getTi_pagreg() == 1 & (a.getTi_pagreg() == 3 | a.getTi_pagreg() == 4)) {//de texto a combo
        $tr.cells[0].innerHTML = a.getNo_pagreg();//<====NO_PAGREG
        if (a.getVa_pagreg() == null)
            a.setVa_pagreg(de.getVa_pagreg());
        var m_select = $D.n_E("SELECT", null, null, null, null, (a.getTi_pagreg() == 3) ? 'input2 q c' : 'input2 q c2', de.getId_valpag(), L);//creo al combo
        if (a.getTi_estreg() == 'L')
            m_select.setAttribute("disabled", "disabled");
        if (de.getTi_estreg() == 'O') {
            var tr_f = $D.g_ID("tr_" + de.getId_valpag());
            tr_f.removeAttribute('style');
        }

        var c_js_o = $D.getJSON(url);//consigo
        if (a.getTi_pagreg() == 3) {
            var optn_b = $D.n_E("OPTION");
            m_select.options.add(optn_b);
        }
        var coincidencia = false;
        for (var ic2 = 0; ic2 < c_js_o.length; ic2++) {
            var optn = $D.n_E("OPTION");
            optn.text = c_js_o[ic2].no_compag;
            if (a.getVa_pagreg() == c_js_o[ic2].co_compag) {
                optn.selected = "selected";
                coincidencia = true;
            }
            optn.value = c_js_o[ic2].co_compag;
            m_select.options.add(optn);
        }
        m_select.setAttribute("onchange", onchange);
        m_select.setAttribute("maxlength", de.getCa_carcol());

        $tr.cells[1].innerHTML = "";
        $tr.cells[1].appendChild(m_select);

        return coincidencia;
    } else if (de.getTi_pagreg() == 1 & a.getTi_pagreg() == 5) {//de texto a radiobutton
        $tr.cells[0].innerHTML = a.getNo_pagreg();//<====NO_PAGREG
        if (a.getVa_pagreg() == null)
            a.setVa_pagreg(de.getVa_pagreg());

        var c_js_o = $D.getJSON(url);
        var coincidencia = false;
        if (!isError(c_js_o)) {
            var va_val = $D.g_ID(de.getId_valpag());//input hidden
            var val_onchange = va_val.getAttribute("onchange");

            var m_tabla = $D.n_E("table", null, null, null, null, null, de.getId_valpag() + "_table_radio", null, 'padding: 0px; margin: 0px;');
            m_tabla.setAttribute("width", "100%");
            m_tabla.setAttribute("cellpadding", "0");
            m_tabla.setAttribute("cellspacing", "0");
            var m_tr = $D.n_E("tr", null, null, null, null, null, de.getId_valpag() + "_tr", null, 'padding: 0px; margin: 0px; height: 16px;');
            m_tabla.appendChild(m_tr);

            var coincidencia = false;
            if (!(a.length > 0))
                de.setVa_pagreg(a.getVa_pagreg());
            for (var ic2 = 0; ic2 < c_js_o.length; ic2++) {
                var n_td_1 = $D.n_E("td", null, null, null, null, 'input2', null, null, 'border-width: 0px; margin: 0px; padding: 0px; height: 16px;');
                n_td_1.width = "2%";
                var n_rd = $D.n_E("input", 'r_' + va_val.getAttribute("id"), 'radio', c_js_o[ic2].co_compag, null, 'input2', de.getId_valpag() + "_" + ic2, null, 'padding: 0px; margin: 0px 0px 0px 0px; height: 12px;border:0px white;', null, null);
                n_rd.setAttribute("onclick", "actualizaradio(this,'" + de.getId_valpag() + "')");
                if (a.getTi_estreg() == 'L')
                    n_rd.setAttribute("disabled", "disabled");

                if (a.getVa_pagreg() == c_js_o[ic2].co_compag) {
                    n_rd.setAttribute("checked", "");
                    coincidencia = true;
                }

                n_td_1.appendChild(n_rd);//agregando el radio al primer td
                m_tr.appendChild(n_td_1);//agregando el primer td al tr
                var n_td_2 = $D.n_E("td", null, null, null, null, 'tdPagina4', null, null, 'border-color: white; padding: 1px 4px 0px 1px;');
                var n_lb = $D.n_E("label", null, null, null, c_js_o[ic2].no_compag, null, de.getId_valpag() + "_" + ic2 + "_l");
                n_lb.setAttribute("for", de.getId_valpag() + "_" + ic2);
                n_td_2.appendChild(n_lb);//agregando el label al segundo td
                m_tr.appendChild(n_td_2);//agregando el segundo td al tr
            }
            var m_input = $D.n_E("input", null, 'hidden', de.getVa_pagreg(), null, 'iqaro radio', de.getId_valpag(), null, null, null, val_onchange);
            m_input.setAttribute("size", de.getCa_carcol());
            $tr.cells[1].innerHTML = "";
            var t = $D.n_E('label');
            t.appendChild(m_tabla);
            $tr.cells[1].innerHTML = t.innerHTML;
            $tr.cells[1].appendChild(m_input);
        } else {
            throw c_js_o;
        }
        $tr.cells[1].innerHTML = "";
        $tr.cells[1].appendChild(m_tabla);
        $tr.cells[1].appendChild(m_input);

    } else if (de.getTi_pagreg() == 1 & a.getTi_pagreg() == 7) {//de texto a fecha
        $tr.cells[0].innerHTML = a.getNo_pagreg();
        if (a.getVa_pagreg() == null)
            a.setVa_pagreg(de.getVa_pagreg());

        var coincidencia = false;

        var m_tabla = $D.n_E("table", null, null, null, null, null, "tr_td2_" + de.getId_valpag() + "_table_fecha", null, null);

        var m_tabla_b = $D.n_E("tbody");
        m_tabla.appendChild(m_tabla_b);

        var m_tr = $D.n_E("tr");
        m_tabla_b.appendChild(m_tr);

        var m_td1 = $D.n_E("td");

        var m_input1 = $D.n_E("input", "ff_dia" + de.getId_valpag().replace("v", ""), 'text', null, null, "i2 dd", "ff_dia" + de.getId_valpag().replace("v", ""), null, 'width: 18px;', null, "texto_fecha('" + de.getId_valpag().replace("v", "") + "');");
        m_input1.setAttribute("onkeypress", "nn_Key()");
        m_input1.setAttribute("onkeyup", "nn_Key();texto_fecha('" + de.getId_valpag().replace("v", "") + "');");
        m_input1.setAttribute("maxlength", "2");
        m_input1.setAttribute("size", "1");
        try {
            if (a.getVa_pagreg().length > 0) {
                m_input1.setAttribute("value", a.getVa_pagreg().substring(8, 10));
            }
            else
                m_input1.setAttribute("value", de.getVa_pagreg().substring(8, 10));
        } catch (e) {
            m_input1.setAttribute("value", de.getVa_pagreg().substring(8, 10));
        }
        if (a.getTi_estreg() == 'L')
            m_input1.setAttribute("readonly", "readonly");
        m_input1.setAttribute("placeholder", "dd");
        m_td1.appendChild(m_input1);
        m_td1.appendChild(document.createTextNode("/"));

        var m_input2 = $D.n_E("input", "ff_mes" + de.getId_valpag().replace("v", ""), 'text', null, null, "i2 mm", "ff_mes" + de.getId_valpag().replace("v", ""), null, 'width: 18px;', null, "texto_fecha('" + de.getId_valpag().replace("v", "") + "');");
        m_input2.setAttribute("onkeypress", "nn_Key()");
        m_input2.setAttribute("onkeyup", "nn_Key();texto_fecha('" + de.getId_valpag().replace("v", "") + "');");
        m_input2.setAttribute("maxlength", "2");
        m_input2.setAttribute("size", "1");
        try {
            if (a.getVa_pagreg().length > 0) {
                m_input2.setAttribute("value", a.getVa_pagreg().substring(5, 7));
            }
            else
                m_input2.setAttribute("value", de.getVa_pagreg().substring(5, 7));
        } catch (e) {
            m_input2.setAttribute("value", de.getVa_pagreg().substring(5, 7));
        }
        if (a.getTi_estreg() == 'L')
            m_input2.setAttribute("readonly", "readonly");
        m_input2.setAttribute("placeholder", "mm");
        m_td1.appendChild(m_input2);

        m_td1.appendChild(document.createTextNode("/"));

        var m_input3 = $D.n_E("input", "ff_anio" + de.getId_valpag().replace("v", ""), 'text', null, null, "i2 yy", "ff_anio" + de.getId_valpag().replace("v", ""), null, 'width: 26px;', null, "texto_fecha('" + de.getId_valpag().replace("v", "") + "');");
        m_input3.setAttribute("onkeypress", "nn_Key()");
        m_input3.setAttribute("onkeyup", "nn_Key();texto_fecha('" + de.getId_valpag().replace("v", "") + "');");
        m_input3.setAttribute("maxlength", "4");
        m_input3.setAttribute("size", "4");
        try {
            if (a.getVa_pagreg().length > 0) {
                m_input3.setAttribute("value", a.getVa_pagreg().substring(0, 4));
            }
            else
                m_input3.setAttribute("value", de.getVa_pagreg().substring(0, 4));
        } catch (e) {
            m_input3.setAttribute("value", de.getVa_pagreg().substring(0, 4));
        }
        if (a.getTi_estreg() == 'L')
            m_input3.setAttribute("readonly", "readonly");
        m_input3.setAttribute("placeholder", "yyyy");
        m_td1.appendChild(m_input3);

        m_tr.appendChild(m_td1);//agregado el tercer td


        var m_td6 = $D.n_E("td", null, null, null, null, 'slash', null, null, null);
        if (a.getTi_estreg() == 'L')
            m_td6.setAttribute("style", "padding: 0px 2px 0px 2px; margin: 0px; height: 14px; border-width: 0px; border-style: solid;display:none;");

        var m_img = $D.n_E("img", null, null, null, null, null, "trigger" + de.getId_valpag().replace("v", ""), null, 'cursor: pointer; border: 1px solid #073362;');
        m_img.setAttribute("align", "middle");
        m_img.setAttribute("src", "js/jscalendar-1.0/img.gif");
        m_img.setAttribute("title", "Seleccione Fecha");
        m_img.setAttribute("onmouseover", "this.style.background='#073362';");
        m_img.setAttribute("onmouseout", "this.style.background=''");
        m_td6.appendChild(m_img);

        m_tr.appendChild(m_td6);//removiendo al co_pag

        $tr.cells[1].innerHTML = "";
        $tr.cells[1].appendChild(m_tabla);

        var m_input4 = $D.n_E("input", "v" + de.getId_valpag().replace("v", ""), 'hidden', null, null, 'q fecha', "v" + de.getId_valpag().replace("v", ""), null, 'width: 40px;', null, "cambio(this,'" + de.getId_valpag().replace("v", "") + "');");
        m_input4.setAttribute("size", de.getCa_carcol());
        try {
            if (a.getVa_pagreg().length > 0) {
                m_input4.setAttribute("value", a.getVa_pagreg());
            }
            else
                m_input4.setAttribute("value", de.getVa_pagreg());
        } catch (e) {
            m_input4.setAttribute("value", de.getVa_pagreg());
        }
        $tr.cells[1].appendChild(m_input4);


        try {
            eval("fechas[fe]='" + de.getId_valpag().replace("v", "") + "';Calendar.setup({inputField     :    'v'+fechas[fe],ifFormat       :    '%Y-%m-%d', button         :    'trigger'+fechas[fe],  align          :    'cc',singleClick    :    true});fe++;$D.g_ID('v" + de.getId_valpag().replace("v", "") + "').onchange();")
        } catch (e) {
            alert("erro en el script:" + e);
        }

    } else if ((de.getTi_pagreg() == 3 | de.getTi_pagreg() == 4 | de.getTi_pagreg() == 5 | de.getTi_pagreg() == 7) & a.getTi_pagreg() == 1) {
        $tr.cells[0].innerHTML = a.getNo_pagreg();//<====NO_PAGREG
        if (a.getVa_pagreg() == null)
            a.setVa_pagreg(de.getVa_pagreg());
        if (a.getTx_pagreg() == null)
            a.setTx_pagreg(de.getTx_pagreg());

        if (a.getTi_estreg() == 'L') {
            var n_label = $D.n_E("label", null, null, null, a.getTx_pagreg(), null, de.getId_valpag(), "", 'height: 16px', null, $D.g_ID(de.getId_valpag()).getAttribute("onblur"));
            n_label.setAttribute("valpag", a.getVa_pagreg());
            n_label.setAttribute("carcol", a.getCa_carcol());
            n_label.setAttribute("rowcol", a.getCa_rowcol());
            $tr.cells[1].innerHTML = "";
            $tr.cells[1].appendChild(n_label);
        } else if (a.getTi_estreg() == 'E') {
            $tr.cells[1].innerHTML = "";
            var n_input = $D.n_E("input", null, "text", a.getTx_pagreg(), null, "q input2", de.getId_valpag(), null, "text-transform: uppercase;", "", null)
            n_input.setAttribute("onkeyup", "toupper(this,event);update(this);");
            n_input.setAttribute("valpag", a.getVa_pagreg());
            n_input.setAttribute("onblur", "" + onchange);
            n_input.setAttribute("valpag", "" + a.getVa_pagreg());
            n_input.setAttribute("size", "" + de.getCa_carcol());
            n_input.setAttribute("maxlength", "" + de.getCa_carcol());
            $tr.cells[1].appendChild(n_input);
        } else if (a.getTi_estreg() == 'O') {
            var tr_f = $D.g_ID("tr_" + de.getId_valpag());
            tr_f.setAttribute('style', "display:none");
            var m_label = $D.n_E("label", null, null, null, null, 'q oculto', de.getId_valpag(), L, 'height: 16px', null, onchange);
            try {
                if (a.getVa_pagreg().length > 0)
                    m_label.setAttribute("name", a.getVa_pagreg());
                else
                    m_label.setAttribute("name", de.getVa_pagreg());
            } catch (e) {
                m_label.setAttribute("name", de.getVa_pagreg());
            }
            try {
                m_label.innerHTML = a.getTx_pagreg();
            } catch (e) {
                m_label.innerHTML = de.getTx_pagreg();
            }

            $tr.cells[1].innerHTML = "";
            $tr.cells[1].appendChild(m_label);
        }
    } else if (de.getTi_pagreg() == 4 & a.getTi_pagreg() == 3) {
        //        var tr_td = $D.g_ID("tr_td1_"+de.getId_valpag()).innerHTML = a.getNo_pagreg();//<====NO_PAGREG
        var componente = $D.g_ID(de.getId_valpag());
        componente.removeAttribute("onchange");
        var c_js_o = $D.getJSON(url);
        componente.innerHTML = "";

        var optn_b = $D.n_E("OPTION");
        componente.options.add(optn_b);
        var coincidencia = false;
        for (var ic2 = 0; ic2 < c_js_o.length; ic2++) {
            var optn = $D.n_E("OPTION");
            optn.text = c_js_o[ic2].no_compag;
            if (a.getVa_pagreg() == c_js_o[ic2].co_compag) {
                optn.selected = "selected";
                coincidencia = true;
            }
            optn.value = c_js_o[ic2].co_compag;
            componente.options.add(optn);
        }
        componente.setAttribute("onchange", onchange);
        if (a.getTi_estreg() == 'L')
            componente.setAttribute("disabled", "disabled");
    } else if (de.getTi_pagreg() == 3 & a.getTi_pagreg() == 4) {
        //        var tr_td = $D.g_ID("tr_td1_"+de.getId_valpag()).innerHTML = a.getNo_pagreg();//<====NO_PAGREG
        var componente = $D.g_ID(de.getId_valpag());
        componente.removeAttribute("onchange");
        var c_js_o = $D.getJSON(url);
        componente.innerHTML = "";
        var coincidencia = false;
        for (var ic2 = 0; ic2 < c_js_o.length; ic2++) {
            var optn = $D.n_E("OPTION");
            optn.text = c_js_o[ic2].no_compag;
            if (a.getVa_pagreg() == c_js_o[ic2].co_compag) {
                optn.selected = "selected";
                coincidencia = true;
            }
            optn.value = c_js_o[ic2].co_compag;
            componente.options.add(optn);
        }
        componente.setAttribute("onchange", onchange);
        if (a.getTi_estreg() == 'L')
            componente.setAttribute("disabled", "disabled");
    } else if (de.getTi_pagreg() == 1 & a.getTi_pagreg() == 22) {
        if ((de.getTi_estreg() == 'L' | de.getTi_estreg() == 'O') & a.getTi_estreg() == 'E') {
            $tr.cells[0].innerHTML = a.getNo_pagreg();

            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }

            var n_input = $D.n_E("input", null, "text", de.getVa_pagreg(), null, "q input2", de.getId_valpag(), null, null, "", null)
            n_input.setAttribute("onkeydown", "if(event.keyCode==13) event.keyCode=9;");
            n_input.setAttribute("onkeypress", "return blockNonNumbers(this, event, false, true);");
            n_input.setAttribute("onkeyup", "extractNumber(this,0,true);");
            n_input.setAttribute("onblur", "extractNumber(this,0,true);");
            //n_input.setAttribute("onblur", ""+onchange);
            //n_input.onblur = onchange;
            n_input.onblur = function () {
                eval(onchange);
            };

            n_input.setAttribute("size", "" + de.getCa_carcol());
            n_input.setAttribute("maxlength", "" + de.getCa_carcol());

            $tr.cells[1].innerHTML = "";
            $tr.cells[1].appendChild(n_input);

            $tr.style.display = "table-row";

        } else if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'O') & a.getTi_estreg() == 'L') {
            $tr.cells[0].innerHTML = a.getNo_pagreg();

            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }

            var n_input = $D.n_E("input", null, "text", de.getVa_pagreg(), null, "q input2", de.getId_valpag(), null, null, "", null)
            n_input.setAttribute("onkeydown", "if(event.keyCode==13) event.keyCode=9;");
            n_input.setAttribute("onkeypress", "return blockNonNumbers(this, event, false, true);");
            n_input.setAttribute("onkeyup", "extractNumber(this,0,true);");
            n_input.setAttribute("onblur", "extractNumber(this,0,true);");
            n_input.setAttribute("readonly", "");
            //n_input.setAttribute("onblur", ""+onchange);
            //n_input.onblur = onchange;
            n_input.onblur = function () {
                eval(onchange);
            };

            n_input.setAttribute("size", "" + de.getCa_carcol());
            n_input.setAttribute("maxlength", "" + de.getCa_carcol());

            $tr.cells[1].innerHTML = "";
            $tr.cells[1].appendChild(n_input);

            $tr.style.display = "table-row";

        } else if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'L') & a.getTi_estreg() == 'O') {
            $tr.cells[0].innerHTML = a.getNo_pagreg();

            $tr.setAttribute('style', "display:none");

            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }
            var n_label = $D.n_E("label", null, null, null, de.getTx_pagreg(), 'q o', de.getId_valpag(), "", 'height: 16px', null, $D.g_ID(de.getId_valpag()).getAttribute("onblur"));
            n_label.setAttribute("valpag", de.getVa_pagreg());
            n_label.setAttribute("carcol", de.getCa_carcol());
            n_label.setAttribute("rowcol", de.getCa_rowcol());

            $tr.cells[1].innerHTML = "";
            $tr.cells[1].appendChild(n_label);

        } else if ((de.getTi_estreg() == 'E') & (a.getTi_estreg() == 'E')) {

            $tr.cells[0].innerHTML = a.getNo_pagreg();
            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
            }
            else {
                de.setVa_pagreg(a.getVa_pagreg());
            }
            componente.setAttribute("value", de.getVa_pagreg());
            componente.value = de.getVa_pagreg();
        } else if ((de.getTi_estreg() == 'L') & (a.getTi_estreg() == 'L')) {

            $tr.cells[0].innerHTML = a.getNo_pagreg();
            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }
            componente.setAttribute("valpag", de.getVa_pagreg());
            componente.innerHTML = de.getTx_pagreg();
        } else if ((de.getTi_estreg() == 'O') & (a.getTi_estreg() == 'O')) {

            $tr.cells[0].innerHTML = a.getNo_pagreg();
            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }
            componente.setAttribute("valpag", de.getTx_pagreg());
            componente.innerHTML = de.getTx_pagreg();
        }

    } else if (de.getTi_pagreg() == 1 & a.getTi_pagreg() == 23) {
        if ((de.getTi_estreg() == 'L' | de.getTi_estreg() == 'O') & a.getTi_estreg() == 'E') {
            $tr.cells[0].innerHTML = a.getNo_pagreg();

            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }

            var n_input = $D.n_E("input", null, "text", de.getVa_pagreg(), null, "q input2", de.getId_valpag(), null, null, "", null)
            n_input.setAttribute("onkeydown", "if(event.keyCode==13) event.keyCode=9;");
            n_input.setAttribute("onkeypress", "return blockNonNumbers(this, event, true, true);");
            n_input.setAttribute("onkeyup", "extractNumber(this,-1,true);");
            n_input.setAttribute("onblur", "extractNumber(this,-1,true);");
            //n_input.setAttribute("onblur", ""+onchange);
            //n_input.onblur = onchange;
            n_input.onblur = function () {
                eval(onchange);
            };

            n_input.setAttribute("size", "" + de.getCa_carcol());
            n_input.setAttribute("maxlength", "" + de.getCa_carcol());

            $tr.cells[1].innerHTML = "";
            $tr.cells[1].appendChild(n_input);

            $tr.style.display = "table-row";

        } else if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'O') & a.getTi_estreg() == 'L') {
            $tr.cells[0].innerHTML = a.getNo_pagreg();

            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }

            var n_input = $D.n_E("input", null, "text", de.getVa_pagreg(), null, "q input2", de.getId_valpag(), null, null, "", null)
            n_input.setAttribute("onkeydown", "if(event.keyCode==13) event.keyCode=9;");
            n_input.setAttribute("onkeypress", "return blockNonNumbers(this, event, true, true);");
            n_input.setAttribute("onkeyup", "extractNumber(this,-1,true);");
            n_input.setAttribute("onblur", "extractNumber(this,-1,true);");
            n_input.setAttribute("readonly", "");
            //n_input.setAttribute("onblur", ""+onchange);
            //n_input.onblur = onchange;
            n_input.onblur = function () {
                eval(onchange);
            };

            n_input.setAttribute("size", "" + de.getCa_carcol());
            n_input.setAttribute("maxlength", "" + de.getCa_carcol());

            $tr.cells[1].innerHTML = "";
            $tr.cells[1].appendChild(n_input);

            $tr.style.display = "table-row";

        } else if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'L') & a.getTi_estreg() == 'O') {
            $tr.cells[0].innerHTML = a.getNo_pagreg();

            $tr.setAttribute('style', "display:none");

            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }
            var n_label = $D.n_E("label", null, null, null, de.getTx_pagreg(), 'q o', de.getId_valpag(), "", 'height: 16px', null, $D.g_ID(de.getId_valpag()).getAttribute("onblur"));
            n_label.setAttribute("valpag", de.getVa_pagreg());
            n_label.setAttribute("carcol", de.getCa_carcol());
            n_label.setAttribute("rowcol", de.getCa_rowcol());

            $tr.cells[1].innerHTML = "";
            $tr.cells[1].appendChild(n_label);

        } else if ((de.getTi_estreg() == 'E') & (a.getTi_estreg() == 'E')) {

            $tr.cells[0].innerHTML = a.getNo_pagreg();
            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
            }
            else {
                de.setVa_pagreg(a.getVa_pagreg());
            }
            componente.setAttribute("value", de.getVa_pagreg());
            componente.value = de.getVa_pagreg();
        } else if ((de.getTi_estreg() == 'L') & (a.getTi_estreg() == 'L')) {

            $tr.cells[0].innerHTML = a.getNo_pagreg();
            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }
            componente.setAttribute("valpag", de.getVa_pagreg());
            componente.innerHTML = de.getTx_pagreg();
        } else if ((de.getTi_estreg() == 'O') & (a.getTi_estreg() == 'O')) {

            $tr.cells[0].innerHTML = a.getNo_pagreg();
            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }
            componente.setAttribute("valpag", de.getTx_pagreg());
            componente.innerHTML = de.getTx_pagreg();
        }
    } else if (de.getTi_pagreg() == 1 & a.getTi_pagreg() == 10) {
        if ((de.getTi_estreg() == 'L' | de.getTi_estreg() == 'O') & a.getTi_estreg() == 'E') {
            $tr.cells[0].innerHTML = a.getNo_pagreg();

            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }

            var n_a = $D.n_E("a", null, "", null, null, null, de.getId_valpag(), null, "display: inline-block;color:#15C;width:175px;", null, null);
            n_a.setAttribute("href", "#");
            n_a.setAttribute("onclick", "vergeolocalizador('labelmultiselect_" + de.getId_valpag().substr(1, de.getId_valpag().length) + "','" + de.getId_valpag() + "',true,'" + a.getCa_carcol() + "',true)");
            n_a.setAttribute("onmouseover", "this.color='#15C;'");
            //            n_a.setAttribute("size", ""+de.getCa_carcol());
            //            n_a.setAttribute("maxlength", ""+de.getCa_carcol());

            var n_im = $D.n_E("img", null, "image", null, null, null, de.getId_valpag(), null, "padding: 0px; margin: -1px 2px; width: 13px; display: table-cell;", null, null);
            n_im.setAttribute("src", "../img/georeferencia.png");
            n_im.setAttribute("valing", "top");
            n_im.setAttribute("aling", "left");

            var n_in = $D.n_E("input", null, "hidden", a.getVa_pagreg(), null, "q", de.getId_valpag(), null, "padding: 0px; margin: -1px 2px; width: 13px; display: table-cell;", null, null);
            var n_la = $D.n_E("label", null, "hidden", null, null, null, de.getId_valpag(), null, "display:none;", null, null);
            n_la.innerHTML = n_la.innerHTML + a.getVa_pagreg()

            n_a.appendChild(n_im);

            if (a.getVa_pagreg() != null)
                n_a.innerHTML = n_a.innerHTML + "Editar";
            else
                n_a.innerHTML = n_a.innerHTML + "Agregar";

            n_a.appendChild(n_in);
            n_a.appendChild(n_la);

            $tr.cells[1].innerHTML = "";
            $tr.cells[1].appendChild(n_a);

            $tr.style.display = "table-row";


        } else if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'O') & a.getTi_estreg() == 'L') {

        } else if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'L') & a.getTi_estreg() == 'O') {

        } else if ((de.getTi_estreg() == 'E') & (a.getTi_estreg() == 'E')) {

        } else if ((de.getTi_estreg() == 'L') & (a.getTi_estreg() == 'L')) {

        } else if ((de.getTi_estreg() == 'O') & (a.getTi_estreg() == 'O')) {

        }
    } else if (de.getTi_pagreg() == 1 & a.getTi_pagreg() == 14) {

        if ((de.getTi_estreg() == 'L' | de.getTi_estreg() == 'O') & a.getTi_estreg() == 'E') {
            $tr.cells[0].innerHTML = a.getNo_pagreg();

            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }

            var n_input = $D.n_E("iframe", null, "", de.getVa_pagreg(), null, "q f", de.getId_valpag(), null, "display: block;height: 18px;border: 0;", null, null)
            n_input.setAttribute("src", "load.jsp");
            n_input.setAttribute("marginheight", "0");
            n_input.setAttribute("marginwidth", "0");
            n_input.setAttribute("scrolling", "none");
            n_input.onblur = function () {
                eval(onchange);
            };

            n_input.setAttribute("size", "" + de.getCa_carcol());
            n_input.setAttribute("maxlength", "" + de.getCa_carcol());

            $tr.cells[1].innerHTML = "";
            $tr.cells[1].appendChild(n_input);

            $tr.style.display = "table-row";

        } else if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'O') & a.getTi_estreg() == 'L') {

        } else if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'L') & a.getTi_estreg() == 'O') {

        } else if ((de.getTi_estreg() == 'E') & (a.getTi_estreg() == 'E')) {

        } else if ((de.getTi_estreg() == 'L') & (a.getTi_estreg() == 'L')) {

        } else if ((de.getTi_estreg() == 'O') & (a.getTi_estreg() == 'O')) {

        }
    } else if (de.getTi_pagreg() == 14 & a.getTi_pagreg() == 10) {
        if ((de.getTi_estreg() == 'L' | de.getTi_estreg() == 'O') & a.getTi_estreg() == 'E') {
//            $tr.cells[0].innerHTML = a.getNo_pagreg();
//            
//            if(a.getVa_pagreg() == null){
//                de.setVa_pagreg(de.getVa_pagreg());
//                de.setTx_pagreg(de.getTx_pagreg());
//            }else{
//                de.setVa_pagreg(a.getVa_pagreg());
//                de.setTx_pagreg(a.getTx_pagreg());
//            }
//            
//            var n_a = $D.n_E("a", null, "", null, null, null, de.getId_valpag(), null, "display: inline-block;color:#15C;width:175px;", null, null);
//            n_a.setAttribute("href", "#");
//            n_a.setAttribute("onclick", "vergeolocalizador('labelmultiselect_"+de.getId_valpag().substr(1, de.getId_valpag().length)+"','"+de.getId_valpag()+"',true,'"+a.getCa_carcol()+"',true)");
//            n_a.setAttribute("onmouseover", "this.color='#15C;'");
//            //            n_a.setAttribute("size", ""+de.getCa_carcol());
//            //            n_a.setAttribute("maxlength", ""+de.getCa_carcol());
//            
//            var n_im = $D.n_E("img", null, "image", null, null, null, de.getId_valpag(), null, "padding: 0px; margin: -1px 2px; width: 13px; display: table-cell;", null, null);
//            n_im.setAttribute("src", "../img/georeferencia.png");
//            n_im.setAttribute("valing", "top");
//            n_im.setAttribute("aling", "left");
//         
//            var n_in = $D.n_E("input", null, "hidden", a.getVa_pagreg(), null, "q", de.getId_valpag(), null, "padding: 0px; margin: -1px 2px; width: 13px; display: table-cell;", null, null);
//            var n_la = $D.n_E("label", null, "hidden", null, null, null, de.getId_valpag(), null, "display:none;", null, null);
//            n_la.innerHTML = n_la.innerHTML + a.getVa_pagreg()
//            
//            n_a.appendChild(n_im);
//            
//            if(a.getVa_pagreg()!=null)n_a.innerHTML = n_a.innerHTML + "Editar";
//            else n_a.innerHTML = n_a.innerHTML + "Agregar";
//                
//            n_a.appendChild(n_in);
//            n_a.appendChild(n_la);
//                        
//            $tr.cells[1].innerHTML = "";
//            $tr.cells[1].appendChild(n_a);

            $tr.style.display = "table-row";

        } else if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'O') & a.getTi_estreg() == 'L') {

        } else if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'L') & a.getTi_estreg() == 'O') {
//            $tr.cells[0].innerHTML = a.getNo_pagreg();

            $tr.style.display = "none";

//            if(a.getVa_pagreg() == null){
//                de.setVa_pagreg(de.getVa_pagreg());
//                de.setTx_pagreg(de.getTx_pagreg());
//            }else{
//                de.setVa_pagreg(a.getVa_pagreg());
//                de.setTx_pagreg(a.getTx_pagreg());
//            }
//            
//            var n_a = $D.n_E("a", null, "", null, null, null, de.getId_valpag(), null, "display: inline-block;color:#15C;width:175px;", null, null);
//            n_a.setAttribute("href", "#");
//            n_a.setAttribute("onclick", "vergeolocalizador('labelmultiselect_"+de.getId_valpag().substr(1, de.getId_valpag().length)+"','"+de.getId_valpag()+"',true,'"+a.getCa_carcol()+"',true)");
//            n_a.setAttribute("onmouseover", "this.color='#15C;'");
//            //            n_a.setAttribute("size", ""+de.getCa_carcol());
//            //            n_a.setAttribute("maxlength", ""+de.getCa_carcol());
//            
//            var n_im = $D.n_E("img", null, "image", null, null, null, de.getId_valpag(), null, "padding: 0px; margin: -1px 2px; width: 13px; display: table-cell;", null, null);
//            n_im.setAttribute("src", "../img/georeferencia.png");
//            n_im.setAttribute("valing", "top");
//            n_im.setAttribute("aling", "left");
//         
//            var n_in = $D.n_E("input", null, "hidden", a.getVa_pagreg(), null, "q", de.getId_valpag(), null, "padding: 0px; margin: -1px 2px; width: 13px; display: table-cell;", null, null);
//            var n_la = $D.n_E("label", null, "hidden", null, null, null, de.getId_valpag(), null, "display:none;", null, null);
//            n_la.innerHTML = n_la.innerHTML + a.getVa_pagreg()
//            
//            n_a.appendChild(n_im);
//            
//            if(a.getVa_pagreg()!=null)n_a.innerHTML = n_a.innerHTML + "Editar";
//            else n_a.innerHTML = n_a.innerHTML + "Agregar";
//                
//            n_a.appendChild(n_in);
//            n_a.appendChild(n_la);
//                        
//            $tr.cells[1].innerHTML = "";
//            $tr.cells[1].appendChild(n_a);
//            

        } else if ((de.getTi_estreg() == 'E') & (a.getTi_estreg() == 'E')) {

        } else if ((de.getTi_estreg() == 'L') & (a.getTi_estreg() == 'L')) {

        } else if ((de.getTi_estreg() == 'O') & (a.getTi_estreg() == 'O')) {

        }
    }

}

function recarga_componente(de, a, onchange, url) {
    //alert("de["+de.getTi_pagreg()+":"+de.getTi_estreg()+"] a["+a.getTi_pagreg()+":"+a.getTi_estreg()+"]");
    if (de.getTi_estreg() == 'O') {
        //var tr_f = $D.g_ID("tr_"+de.getId_valpag());
        //tr_f.removeAttribute('style',"display:none");
    }
    //    alert("de: "+de.getTi_pagreg() +" a: "+a.getTi_pagreg() );    
    var componente = $D.g_ID(de.getId_valpag());//componente a cambiar
    //var $tr = componente.getParent();
    var $tr;

    var m_tr;
    try {
        $tr = componente.getParent();
    } catch (e) {
        try {
            $tr = componente.parentNode;
        } catch (e2) {
        }
    }

    try {
        $tr = $tr.getParent();
    } catch (e2) {
        $tr = $tr.parentNode;
    }

    //$tr = $tr.getParent();//Con esto se consigue el tr de dond ese ubican el titulo y el componente

    if (de.getTi_pagreg() == 1 & a.getTi_pagreg() == 1) {//de texto y texto
        if ((de.getTi_estreg() == 'L' | de.getTi_estreg() == 'O') & a.getTi_estreg() == 'E') {
            $tr.cells[0].innerHTML = a.getNo_pagreg();

            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }

            var n_input = $D.n_E("input", null, "text", de.getVa_pagreg(), null, "q input2", de.getId_valpag(), null, "text-transform: uppercase;", "", null)
            n_input.setAttribute("onkeyup", "toupper(this,event);update(this);");
            //n_input.setAttribute("onblur", ""+onchange);
            //n_input.onblur = onchange;
            n_input.onblur = function () {
                eval(onchange);
            };

            n_input.setAttribute("size", "" + de.getCa_carcol());
            n_input.setAttribute("maxlength", "" + de.getCa_carcol());

            $tr.cells[1].innerHTML = "";
            $tr.cells[1].appendChild(n_input);

            $tr.style.display = "table-row";

        } else if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'O') & a.getTi_estreg() == 'L') {
            //alert("1>2");
            $tr.cells[0].innerHTML = a.getNo_pagreg();

            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }
            var n_label = $D.n_E("label", null, null, null, de.getTx_pagreg(), 'q', de.getId_valpag(), "", 'height: 16px', null, $D.g_ID(de.getId_valpag()).getAttribute("onblur"));
            n_label.setAttribute("valpag", de.getVa_pagreg());
            n_label.setAttribute("carcol", de.getCa_carcol());
            n_label.setAttribute("rowcol", de.getCa_rowcol());

            $tr.cells[1].innerHTML = "";
            $tr.cells[1].appendChild(n_label);
            $tr.style.display = "table-row";

        } else if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'L') & a.getTi_estreg() == 'O') {
            $tr.cells[0].innerHTML = a.getNo_pagreg();

            $tr.setAttribute('style', "display:none");

            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }
            var n_label = $D.n_E("label", null, null, null, de.getTx_pagreg(), 'q o', de.getId_valpag(), "", 'height: 16px', null, $D.g_ID(de.getId_valpag()).getAttribute("onblur"));
            n_label.setAttribute("valpag", de.getVa_pagreg());
            n_label.setAttribute("carcol", de.getCa_carcol());
            n_label.setAttribute("rowcol", de.getCa_rowcol());

            $tr.cells[1].innerHTML = "";
            $tr.cells[1].appendChild(n_label);

        } else if ((de.getTi_estreg() == 'E') & (a.getTi_estreg() == 'E')) {
            //alert("1");
            $tr.cells[0].innerHTML = a.getNo_pagreg();
            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
            }
            else {
                de.setVa_pagreg(a.getVa_pagreg());
            }
            componente.setAttribute("value", de.getVa_pagreg());
            componente.value = de.getVa_pagreg();
        } else if ((de.getTi_estreg() == 'L') & (a.getTi_estreg() == 'L')) {
            $tr.cells[0].innerHTML = a.getNo_pagreg();
            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }
            componente.setAttribute("valpag", de.getVa_pagreg());
            componente.innerHTML = de.getTx_pagreg();
        } else if ((de.getTi_estreg() == 'O') & (a.getTi_estreg() == 'O')) {
            $tr.cells[0].innerHTML = a.getNo_pagreg();
            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }
            componente.setAttribute("valpag", de.getTx_pagreg());
            componente.innerHTML = de.getTx_pagreg();
        }
        return false;
    } else if (de.getTi_pagreg() == 3 & a.getTi_pagreg() == 3) {
        $tr.cells[0].innerHTML = a.getNo_pagreg();
        if (a.getVa_pagreg() == null)
            a.setVa_pagreg(de.getVa_pagreg());
        componente.removeAttribute("onchange");
        var c_js_o = $D.getJSON(url);
        var coincidencia = false;
        if (!isError(c_js_o)) {
            componente.innerHTML = "";
            var optn_b = $D.n_E("OPTION");
            componente.options.add(optn_b);
            for (var ic2 = 0; ic2 < c_js_o.length; ic2++) {
                var optn = $D.n_E("OPTION");
                optn.text = c_js_o[ic2].no_compag;
                if (a.getVa_pagreg() == c_js_o[ic2].co_compag) {
                    optn.selected = "selected";
                    coincidencia = true;
                }
                optn.value = c_js_o[ic2].co_compag;
                componente.options.add(optn);
            }
            componente.setAttribute("onchange", onchange);
            if (a.getTi_estreg() == 'L') {
                componente.setAttribute("disabled", "disabled");
            } else {
                componente.removeAttribute("disabled");
            }
        } else {
            throw c_js_o;
        }

        if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'L' | de.getTi_estreg() == null) & a.getTi_estreg() == 'O') {
            $tr.style.display = "none";
        } else if (a.getTi_estreg() == 'L' | a.getTi_estreg() == 'E') {
            $tr.style.display = "table-row";
        }

    } else if (de.getTi_pagreg() == 4 & a.getTi_pagreg() == 4) {
        $tr.cells[0].innerHTML = a.getNo_pagreg();
        if (a.getVa_pagreg() == null)
            a.setVa_pagreg(de.getVa_pagreg());
        componente.removeAttribute("onchange");
        var c_js_o = $D.getJSON(url);
        var coincidencia = false;
        if (!isError(c_js_o)) {
            componente.innerHTML = "";
            for (var ic2 = 0; ic2 < c_js_o.length; ic2++) {
                var optn = $D.n_E("OPTION");
                optn.text = c_js_o[ic2].no_compag;
                if (a.getVa_pagreg() == c_js_o[ic2].co_compag) {
                    optn.selected = "selected";
                    coincidencia = true;
                }
                optn.value = c_js_o[ic2].co_compag;
                componente.options.add(optn);
            }
            componente.setAttribute("onchange", onchange);
            if (a.getTi_estreg() == 'L')
                componente.setAttribute("disabled", "disabled");
            else {
                componente.removeAttribute("disabled");
            }
        } else {
            throw c_js_o;
        }

        if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'L' | de.getTi_estreg() == null) & a.getTi_estreg() == 'O') {
            $tr.style.display = "none";
        } else if (a.getTi_estreg() == 'L' | a.getTi_estreg() == 'E') {
            $tr.style.display = "table-row";
        }

    } else if (de.getTi_pagreg() == 5 & a.getTi_pagreg() == 5) {
        $tr.cells[0].innerHTML = a.getNo_pagreg();
        if (a.getVa_pagreg() == null)
            a.setVa_pagreg(de.getVa_pagreg());
        var c_js_o = $D.getJSON(url);
        var coincidencia = false;
        if (!isError(c_js_o)) {
            var va_val = $D.g_ID(de.getId_valpag());//input hidden
            var val_onchange = va_val.getAttribute("onchange");

            var m_tabla = $D.n_E("table", null, null, null, null, "pagreg5", null);
            var m_tr = $D.n_E("tr");
            m_tabla.appendChild(m_tr);

            var coincidencia = false;
            if (!(a.length > 0))
                de.setVa_pagreg(a.getVa_pagreg());
            for (var ic2 = 0; ic2 < c_js_o.length; ic2++) {
                var n_td_1 = $D.n_E("td", null, null, null, null, "p5_radio", null);
                var n_rd = $D.n_E("input", 'r_' + va_val.getAttribute("id"), 'radio', c_js_o[ic2].co_compag, null, 'input2', de.getId_valpag() + "_" + ic2, null, 'padding: 0px; margin: 0px 0px 0px 0px; height: 12px;border:0px white;', null, null);
                n_rd.setAttribute("onclick", "actualizaradio(this,'" + de.getId_valpag() + "')");
                if (a.getTi_estreg() == 'L')
                    n_rd.setAttribute("disabled", "disabled");
                if (a.getVa_pagreg() == c_js_o[ic2].co_compag) {
                    n_rd.setAttribute("checked", "");
                    coincidencia = true;
                }
                n_td_1.appendChild(n_rd);//agregando el radio al primer td
                m_tr.appendChild(n_td_1);//agregando el primer td al tr
                var n_td_2 = $D.n_E("td", null, null, null, null, "p5_text", null);
                var n_lb = $D.n_E("label", null, null, null, c_js_o[ic2].no_compag, null, null);
                n_lb.setAttribute("for", de.getId_valpag() + "_" + ic2);
                n_td_2.appendChild(n_lb);//agregando el label al segundo td
                m_tr.appendChild(n_td_2);//agregando el segundo td al tr
            }
            var m_input = $D.n_E("input", null, 'hidden', de.getVa_pagreg(), null, 'q r', de.getId_valpag(), null, null, null, val_onchange);
            $tr.cells[1].innerHTML = "";
            var t = $D.n_E('label');
            t.appendChild(m_tabla);
            $tr.cells[1].innerHTML = t.innerHTML;
            $tr.cells[1].appendChild(m_input);
        } else {
            throw c_js_o;
        }

        if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'L' | de.getTi_estreg() == null) & a.getTi_estreg() == 'O') {
            $tr.style.display = "none";
        }

        return coincidencia;

    } else if (de.getTi_pagreg() == 6 & a.getTi_pagreg() == 6) {
        $tr.cells[0].innerHTML = a.getNo_pagreg();
        if (a.getVa_pagreg() == null)
            a.setVa_pagreg(de.getVa_pagreg());

        if (a.getVa_pagreg() == '1')
            $D.g_ID(de.getId_valpag()).setAttribute("checked", "");
        else
            $D.g_ID(de.getId_valpag()).removeAttribute("checked");

        var coincidencia = false;
        if (a.getTi_estreg() == 'L') {
            $D.g_ID(de.getId_valpag()).setAttribute("disabled", "disabled");
        } else {
            $D.g_ID(de.getId_valpag()).removeAttribute("disabled");
        }
        return false;
    } else if (de.getTi_pagreg() == 7 & a.getTi_pagreg() == 7) {
        $tr.cells[0].innerHTML = a.getNo_pagreg();

        var coincidencia = false;
        var va_val = $D.g_ID(de.getId_valpag());//input hidden
        var m_tabla = $D.n_E("table", null, null, null, null, "pagreg7", "tr_td2_" + de.getId_valpag() + "_table_fecha", null, null);

        var m_tabla_b = $D.n_E("tbody");
        m_tabla.appendChild(m_tabla_b);

        var m_tr = $D.n_E("tr");
        m_tabla_b.appendChild(m_tr);

        var m_td1 = $D.n_E("td");

        var m_input1 = $D.n_E("input", "ff_dia" + de.getId_valpag().replace("v", ""), 'text', null, null, "i2 dd", "ff_dia" + de.getId_valpag().replace("v", ""), null, 'width: 18px;', null, "texto_fecha('" + de.getId_valpag().replace("v", "") + "');");

        m_input1.setAttribute("onkeypress", "nn_Key()");
        m_input1.setAttribute("onkeyup", "nn_Key();texto_fecha('" + de.getId_valpag().replace("v", "") + "');");
        m_input1.setAttribute("maxlength", "2");
        m_input1.setAttribute("size", "1");

        try {
            if (a.getVa_pagreg() == null) {
                m_input1.setAttribute("value", de.getVa_pagreg().substring(8, 10));
            } else if (a.getVa_pagreg().length < 10) {
                m_input1.setAttribute("value", "");
            } else {
                m_input1.setAttribute("value", a.getVa_pagreg().substring(8, 10));
            }
        } catch (e) {
            m_input1.setAttribute("value", de.getVa_pagreg().substring(8, 10));
        }

        if (a.getTi_estreg() == 'L')
            m_input1.setAttribute("readonly", "readonly");
        m_input1.setAttribute("placeholder", "dd");
        m_td1.appendChild(m_input1);
        m_td1.appendChild(document.createTextNode("/"));

        var m_input2 = $D.n_E("input", "ff_mes" + de.getId_valpag().replace("v", ""), 'text', null, null, 'i2 mm', "ff_mes" + de.getId_valpag().replace("v", ""), null, 'width: 18px;', null, "texto_fecha('" + de.getId_valpag().replace("v", "") + "');");
        m_input2.setAttribute("onkeypress", "nn_Key()");
        m_input2.setAttribute("onkeyup", "nn_Key();texto_fecha('" + de.getId_valpag().replace("v", "") + "');");
        m_input2.setAttribute("maxlength", "2");
        m_input2.setAttribute("size", "1");

        try {
            if (a.getVa_pagreg() == null) {
                m_input2.setAttribute("value", de.getVa_pagreg().substring(5, 7));
            } else if (a.getVa_pagreg().length < 10) {
                m_input2.setAttribute("value", "");
            } else {
                m_input2.setAttribute("value", a.getVa_pagreg().substring(5, 7));
            }
        } catch (e) {
            m_input2.setAttribute("value", de.getVa_pagreg().substring(5, 7));
        }

        if (a.getTi_estreg() == 'L')
            m_input2.setAttribute("readonly", "readonly");
        m_input2.setAttribute("placeholder", "mm");
        m_td1.appendChild(m_input2);
        m_td1.appendChild(document.createTextNode("/"));

        var m_input3 = $D.n_E("input", "ff_anio" + de.getId_valpag().replace("v", ""), 'text', null, null, 'i2 yy', "ff_anio" + de.getId_valpag().replace("v", ""), null, 'width: 26px;', null, "texto_fecha('" + de.getId_valpag().replace("v", "") + "');");
        m_input3.setAttribute("onkeypress", "nn_Key()");
        m_input3.setAttribute("onkeyup", "nn_Key();texto_fecha('" + de.getId_valpag().replace("v", "") + "');");
        m_input3.setAttribute("maxlength", "4");
        m_input3.setAttribute("size", "4");

        try {
            if (a.getVa_pagreg() == null) {
                m_input3.setAttribute("value", de.getVa_pagreg().substring(0, 4));
            } else if (a.getVa_pagreg().length < 10) {
                m_input3.setAttribute("value", "");
            } else {
                m_input3.setAttribute("value", a.getVa_pagreg().substring(0, 4));
            }
        } catch (e) {
            m_input3.setAttribute("value", de.getVa_pagreg().substring(0, 4));
        }

        if (a.getTi_estreg() == 'L')
            m_input3.setAttribute("readonly", "readonly");
        m_input3.setAttribute("placeholder", "yyyy");
        m_td1.appendChild(m_input3);

        m_tr.appendChild(m_td1);//agregado el tercer td


        var m_td6 = $D.n_E("td", null, null, null, null, 'slash', null, null, null);
        if (a.getTi_estreg() == 'L')
            m_td6.setAttribute("style", "padding: 0px 2px 0px 2px; margin: 0px; height: 14px; border-width: 0px; border-style: solid;display:none;");

        var m_img = $D.n_E("img", null, null, null, null, null, "trigger" + de.getId_valpag().replace("v", ""), null, 'cursor: pointer; height: 13px;');
        m_img.setAttribute("align", "middle");
        m_img.setAttribute("src", "js/jscalendar-1.0/img.gif");
        m_img.setAttribute("title", "Seleccione Fecha");
        m_img.setAttribute("onmouseover", "this.style.background='#073362';");
        m_img.setAttribute("onmouseout", "this.style.background=''");
        m_td6.appendChild(m_img);

        m_tr.appendChild(m_td6);//removiendo al co_pag

        $tr.cells[1].innerHTML = "";
        $tr.cells[1].appendChild(m_tabla);

        var m_input4 = $D.n_E("input", "v" + de.getId_valpag().replace("v", ""), 'hidden', null, null, 'q f', "v" + de.getId_valpag().replace("v", ""), null, 'width: 40px;', null, onchange + ";");
        try {
            if (a.getVa_pagreg() == null) {
                m_input4.setAttribute("value", de.getVa_pagreg());
            } else if (a.getVa_pagreg().length < 10) {
                m_input4.setAttribute("value", "");
            } else {
                m_input4.setAttribute("value", a.getVa_pagreg());
            }
        } catch (e) {
            m_input4.setAttribute("value", de.getVa_pagreg());
        }
        $tr.cells[1].appendChild(m_input4);


        try {
            eval("fechas[fe]='" + de.getId_valpag().replace("v", "") + "';Calendar.setup({inputField     :    'v'+fechas[fe],ifFormat       :    '%Y-%m-%d', button         :    'trigger'+fechas[fe],  align          :    'cc',singleClick    :    true});fe++;$D.g_ID('v" + de.getId_valpag().replace("v", "") + "').onchange();")
        } catch (e) {/*alert("error en el script:"+e);*/
        }

        if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'L' | de.getTi_estreg() == null | de.getTi_estreg() == undefined) & a.getTi_estreg() == 'O') {
            $tr.style.display = "none";
        } else if (a.getTi_estreg() == 'L' | a.getTi_estreg() == 'E') {
            $tr.style.display = "table-row";
        }
    } else if (de.getTi_pagreg() == 9 & a.getTi_pagreg() == 9) {
        $tr.cells[0].innerHTML = a.getNo_pagreg();
        if (a.getVa_pagreg() == null)
            a.setVa_pagreg(de.getVa_pagreg());
        var c_js_o = $D.getJSON(url);
        var coincidencia = false;
        $D.g_ID(de.getId_valpag()).value = a.getVa_pagreg();
        if (a.getTi_estreg() == 'L')
            $D.g_ID(de.getId_valpag()).setAttribute("readonly", "readonly");
        else {
            $D.g_ID(de.getId_valpag()).removeAttribute("readonly");
        }

        if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'L' | de.getTi_estreg() == null | de.getTi_estreg() == undefined) & a.getTi_estreg() == 'O') {
            $tr.style.display = "none";
        } else if (a.getTi_estreg() == 'L' | a.getTi_estreg() == 'E') {
            $tr.style.display = "table-row";
        }

    } else if (de.getTi_pagreg() == 10 & a.getTi_pagreg() == 10) {
        $tr.cells[0].innerHTML = a.getNo_pagreg();
        if (a.getVa_pagreg() == null)
            a.setVa_pagreg(de.getVa_pagreg());
        var coincidencia = false;

        if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'L' | de.getTi_estreg() == null | de.getTi_estreg() == undefined) & a.getTi_estreg() == 'O') {
            $tr.style.display = "none";
        } else if (a.getTi_estreg() == 'L' | a.getTi_estreg() == 'E') {
            $tr.style.display = "table-row";
        }

    } else if (de.getTi_pagreg() == 14 & a.getTi_pagreg() == 14) {
        $tr.cells[0].innerHTML = a.getNo_pagreg();
        if (a.getVa_pagreg() == null)
            a.setVa_pagreg(de.getVa_pagreg());
        var coincidencia = false;

        if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'L' | de.getTi_estreg() == null | de.getTi_estreg() == undefined) & a.getTi_estreg() == 'O') {
            $tr.style.display = "none";
        } else if (a.getTi_estreg() == 'L' | a.getTi_estreg() == 'E') {
            $tr.style.display = "table-row";
        }

        return false;
    } else if (de.getTi_pagreg() == 22 & a.getTi_pagreg() == 22) {//de texto y texto numerico entero

        if ((de.getTi_estreg() == 'L' | de.getTi_estreg() == 'O') & a.getTi_estreg() == 'E') {
            $tr.cells[0].innerHTML = a.getNo_pagreg();

            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }

            var n_input = $D.n_E("input", null, "text", de.getVa_pagreg(), null, "q input2", de.getId_valpag(), null, null, "", null)
            n_input.setAttribute("onkeydown", "if(event.keyCode==13) event.keyCode=9;");
            n_input.setAttribute("onkeypress", "return blockNonNumbers(this, event, false, true);");
            n_input.setAttribute("onkeyup", "extractNumber(this,0,true);");
            n_input.setAttribute("onblur", "extractNumber(this,0,true);");
            //n_input.setAttribute("onblur", ""+onchange);
            //n_input.onblur = onchange;
            n_input.onblur = function () {
                eval(onchange);
            };

            n_input.setAttribute("size", "" + de.getCa_carcol());
            n_input.setAttribute("maxlength", "" + de.getCa_carcol());

            $tr.cells[1].innerHTML = "";
            $tr.cells[1].appendChild(n_input);

            $tr.style.display = "table-row";

        } else if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'O') & a.getTi_estreg() == 'L') {
            $tr.cells[0].innerHTML = a.getNo_pagreg();

            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }

            var n_input = $D.n_E("input", null, "text", de.getVa_pagreg(), null, "q input2", de.getId_valpag(), null, null, "", null)
            n_input.setAttribute("onkeydown", "if(event.keyCode==13) event.keyCode=9;");
            n_input.setAttribute("onkeypress", "return blockNonNumbers(this, event, false, true);");
            n_input.setAttribute("onkeyup", "extractNumber(this,0,true);");
            n_input.setAttribute("onblur", "extractNumber(this,0,true);");
            n_input.setAttribute("readonly", "");
            //n_input.setAttribute("onblur", ""+onchange);
            //n_input.onblur = onchange;
            n_input.onblur = function () {
                eval(onchange);
            };

            n_input.setAttribute("size", "" + de.getCa_carcol());
            n_input.setAttribute("maxlength", "" + de.getCa_carcol());

            $tr.cells[1].innerHTML = "";
            $tr.cells[1].appendChild(n_input);

            $tr.style.display = "table-row";

        } else if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'L') & a.getTi_estreg() == 'O') {
            $tr.cells[0].innerHTML = a.getNo_pagreg();

            $tr.setAttribute('style', "display:none");

            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }
            var n_label = $D.n_E("label", null, null, null, de.getTx_pagreg(), 'q o', de.getId_valpag(), "", 'height: 16px', null, $D.g_ID(de.getId_valpag()).getAttribute("onblur"));
            n_label.setAttribute("valpag", de.getVa_pagreg());
            n_label.setAttribute("carcol", de.getCa_carcol());
            n_label.setAttribute("rowcol", de.getCa_rowcol());

            $tr.cells[1].innerHTML = "";
            $tr.cells[1].appendChild(n_label);

        } else if ((de.getTi_estreg() == 'E') & (a.getTi_estreg() == 'E')) {

            $tr.cells[0].innerHTML = a.getNo_pagreg();
            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
            }
            else {
                de.setVa_pagreg(a.getVa_pagreg());
            }
            componente.setAttribute("value", de.getVa_pagreg());
            componente.value = de.getVa_pagreg();
        } else if ((de.getTi_estreg() == 'L') & (a.getTi_estreg() == 'L')) {

            $tr.cells[0].innerHTML = a.getNo_pagreg();
            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }
            componente.setAttribute("valpag", de.getVa_pagreg());
            componente.innerHTML = de.getTx_pagreg();
        } else if ((de.getTi_estreg() == 'O') & (a.getTi_estreg() == 'O')) {

            $tr.cells[0].innerHTML = a.getNo_pagreg();
            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }
            componente.setAttribute("valpag", de.getTx_pagreg());
            componente.innerHTML = de.getTx_pagreg();
        }
        return false;
    } else if (de.getTi_pagreg() == 23 & a.getTi_pagreg() == 23) {//de texto y texto numerico entero
        if ((de.getTi_estreg() == 'L' | de.getTi_estreg() == 'O') & a.getTi_estreg() == 'E') {
            $tr.cells[0].innerHTML = a.getNo_pagreg();

            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }

            var n_input = $D.n_E("input", null, "text", de.getVa_pagreg(), null, "q input2", de.getId_valpag(), null, null, "", null)
            n_input.setAttribute("onkeydown", "if(event.keyCode==13) event.keyCode=9;");
            n_input.setAttribute("onkeypress", "return blockNonNumbers(this, event, true, true);");
            n_input.setAttribute("onkeyup", "extractNumber(this,-1,true);");
            n_input.setAttribute("onblur", "extractNumber(this,-1,true);");
            //n_input.setAttribute("onblur", ""+onchange);
            //n_input.onblur = onchange;
            n_input.onblur = function () {
                eval(onchange);
            };

            n_input.setAttribute("size", "" + de.getCa_carcol());
            n_input.setAttribute("maxlength", "" + de.getCa_carcol());

            $tr.cells[1].innerHTML = "";
            $tr.cells[1].appendChild(n_input);

            $tr.style.display = "table-row";

        } else if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'O') & a.getTi_estreg() == 'L') {
            $tr.cells[0].innerHTML = a.getNo_pagreg();

            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }

            var n_input = $D.n_E("input", null, "text", de.getVa_pagreg(), null, "q input2", de.getId_valpag(), null, null, "", null)
            n_input.setAttribute("onkeydown", "if(event.keyCode==13) event.keyCode=9;");
            n_input.setAttribute("onkeypress", "return blockNonNumbers(this, event, true, true);");
            n_input.setAttribute("onkeyup", "extractNumber(this,-1,true);");
            n_input.setAttribute("onblur", "extractNumber(this,-1,true);");
            n_input.setAttribute("readonly", "");
            //n_input.setAttribute("onblur", ""+onchange);
            //n_input.onblur = onchange;
            n_input.onblur = function () {
                eval(onchange);
            };

            n_input.setAttribute("size", "" + de.getCa_carcol());
            n_input.setAttribute("maxlength", "" + de.getCa_carcol());

            $tr.cells[1].innerHTML = "";
            $tr.cells[1].appendChild(n_input);

            $tr.style.display = "table-row";

        } else if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'L') & a.getTi_estreg() == 'O') {
            $tr.cells[0].innerHTML = a.getNo_pagreg();

            $tr.setAttribute('style', "display:none");

            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }
            var n_label = $D.n_E("label", null, null, null, de.getTx_pagreg(), 'q o', de.getId_valpag(), "", 'height: 16px', null, $D.g_ID(de.getId_valpag()).getAttribute("onblur"));
            n_label.setAttribute("valpag", de.getVa_pagreg());
            n_label.setAttribute("carcol", de.getCa_carcol());
            n_label.setAttribute("rowcol", de.getCa_rowcol());

            $tr.cells[1].innerHTML = "";
            $tr.cells[1].appendChild(n_label);

        } else if ((de.getTi_estreg() == 'E') & (a.getTi_estreg() == 'E')) {

            $tr.cells[0].innerHTML = a.getNo_pagreg();
            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
            }
            else {
                de.setVa_pagreg(a.getVa_pagreg());
            }
            componente.setAttribute("value", de.getVa_pagreg());
            componente.value = de.getVa_pagreg();
        } else if ((de.getTi_estreg() == 'L') & (a.getTi_estreg() == 'L')) {

            $tr.cells[0].innerHTML = a.getNo_pagreg();
            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }
            componente.setAttribute("valpag", de.getVa_pagreg());
            componente.innerHTML = de.getTx_pagreg();
        } else if ((de.getTi_estreg() == 'O') & (a.getTi_estreg() == 'O')) {

            $tr.cells[0].innerHTML = a.getNo_pagreg();
            if (a.getVa_pagreg() == null) {
                de.setVa_pagreg(de.getVa_pagreg());
                de.setTx_pagreg(de.getTx_pagreg());
            } else {
                de.setVa_pagreg(a.getVa_pagreg());
                de.setTx_pagreg(a.getTx_pagreg());
            }
            componente.setAttribute("valpag", de.getTx_pagreg());
            componente.innerHTML = de.getTx_pagreg();
        }
        return false;
    } else if (de.getTi_pagreg() == 44 & a.getTi_pagreg() == 44) {
        if ((de.getTi_estreg() == 'L' | de.getTi_estreg() == 'E') & a.getTi_estreg() == 'O') {
            $tr.cells[0].innerHTML = a.getNo_pagreg();
            $tr.setAttribute('style', "display:none");
            $D.g_ID(de.getId_valpag()).setAttribute("estado", "O");

        } else if (de.getTi_estreg() == 'O' & (a.getTi_estreg() == 'E' | a.getTi_estreg() == 'L')) {
            $tr.cells[0].innerHTML = a.getNo_pagreg();
            $D.g_ID(de.getId_valpag()).setAttribute("estado", "E");
            $tr.setAttribute('style', "display:table-row");
        }
    }
}

function valpag_pos_tr(component, co_pagreg, co_pagina, contenedor, id_frawor) {
    var va_pagreg = get_value_from_componente(component);//PARA CONSERVAR EL VALOR DEL COMPONENTE
    console.log($D.base()+"/wfp?xact=1&co_pagreg=" + co_pagreg + "&va_pagreg=" + va_pagreg + "&co_pagina=" + co_pagina + "&contenedor=" + contenedor + "&id_frawor=" + id_frawor);
    var js_o = $D.getJSON($D.base()+"/wfp?xact=1&co_pagreg=" + co_pagreg + "&va_pagreg=" + va_pagreg + "&co_pagina=" + co_pagina + "&contenedor=" + contenedor + "&id_frawor=" + id_frawor);//CONSEGUIR LA LISTA DE ITEM A CONTROLAR
    console.log(js_o);
    var TR;
    try {
        TR = component.getParent();
    } catch (e) {
        TR = component.parentNode;
    }

    try {
        TR = TR.getParent();
    } catch (e) {
        TR = TR.parentNode;
    }

    try {
        TR = TR.getParent();
    } catch (e) {
        TR = TR.parentNode;
    }


    console.log(">" + TR.tagName);
    console.log(">" + TR.innerHTML);

    try {
        var mi_L = get_value_from_componente_L(component);
        if (js_o != null) {
            for (var i = 0; i < js_o.length; i++) {
                console.log(">>" + "js_o:" + js_o[i].id_valpag);
                var valpag_a = new Xalpag(js_o[i], null);
                //var componente = $D.g_ID(""+co_pagina+"_"+0+"_"+valpag_a.getCo_pagreg());
                console.log(">>" + "val_pag_a:" + valpag_a.id_valpag + "::" + component.id + "::" + valpag_a.co_pagreg + "::" + valpag_a.getCo_pagreg());
                var componente = null;
                try {
                    var li = getElementsByClassName(TR, "q");
                    for (var d = 0; d < li.length; d++) {
                        if (li[d].id == valpag_a.getCo_pagreg()) {
                            componente = li[d];
                            d = li.length;
                        }
                    }
                    //componente = TR.getElementById(""+valpag_a.getCo_pagreg());
                } catch (e) {
                    console.log(e);
                }
                console.log(">>" + "componente:" + componente + "::" + componente.id + "::" + componente.innerHTML);
                var valpag_de = new Xalpag(null, componente);
                console.log(">>" + "valpag_de:" + valpag_de);
                var uri = $D.base()+"/wfp?xact=2&co_pagreg=" + co_pagreg + "&va_pagreg=" + va_pagreg + "&co_regist=" + valpag_a.getCo_pagreg() + "&co_pagina=" + co_pagina + "&contenedor=" + contenedor + "&id_frawor=" + id_frawor;
                var xyh;
                if (mi_L >= get_value_from_componente_L(componente)) {
                    if (valpag_de.getTi_pagreg() == valpag_a.getTi_pagreg()) {
                        console.log(">recargar");
                        recarga_componente_tr(valpag_de, valpag_a, componente.getAttribute("onchange"), uri, 0, TR);
                    } else {
                        //var f= "va_regist_"+co_pagina+"_"+0+"_"+valpag_a.getCo_pagreg();
                        console.log(">actualizar");
                        xyh = actualiza_componente_tr(valpag_de, valpag_a, componente.getAttribute("onchange"), uri, mi_L);
                        if (xyh) {
                            put_value_to_componente_L($D.g_ID("va_regist_" + co_pagina + "_" + 0 + "_" + valpag_a.getCo_pagreg()));
                            $D.g_ID("va_regist_" + co_pagina + "_" + 0 + "_" + valpag_a.getCo_pagreg()).onchange();
                            remove_value_to_componente_L($D.g_ID("va_regist_" + co_pagina + "_" + 0 + "_" + valpag_a.getCo_pagreg()));
                        }
                    }
                } else {
                    xyh = remove_value_to_componente_L(componente);
                    if (xyh) {
                        put_value_to_componente_L($D.g_ID("va_regist_" + co_pagina + "_" + 0 + "_" + valpag_a.getCo_pagreg()));
                        $D.g_ID("va_regist_" + co_pagina + "_" + 0 + "_" + valpag_a.getCo_pagreg()).onchange();
                        remove_value_to_componente_L($D.g_ID("va_regist_" + co_pagina + "_" + 0 + "_" + valpag_a.getCo_pagreg()));
                    }
                }
            }
        } else {
            mensaje(null, 'El juego de valores de [valpagpos] ha retornado nulo.', null, null, 3);
        }
    } catch (e) {
        e = e.toString();

        if (js_o.indexOf("[E]") != -1)
            e = js_o;
        else
            e = e.toString();

        if (e == "TypeError: js_o[0] is undefined" | e == "TypeError: Cannot read property 'id_valpag' of undefined") {
            mensaje('Error - Valpagpos(undefined)', e, null, null, 3);
        } else {
            mensaje('Error - Valpagpos', e, null, null, 3);
        }

    }
}

function recarga_componente_tr(de, a, onchange, url, linea, TR) {
    if (de.getTi_estreg() == 'O') {
        var tr_f = $D.g_ID("tr_" + de.getId_valpag());
        tr_f.removeAttribute('style', "display:none");
    }
    console.log("de.getTi_pagreg():" + de.getTi_pagreg() + "/" + de.getTi_estreg() + "/" + de.id_valpag + "::: a.getTi_pagreg():" + a.getTi_pagreg() + "/" + a.getTi_estreg() + "/" + a.id_valpag);
    if (de.getTi_pagreg() == 1 & a.getTi_pagreg() == 1) {//de texto y texto
        if ((de.getTi_estreg() == 'L' | de.getTi_estreg() == 'O') & a.getTi_estreg() == 'E') {
            var tr_td2;
            try {
                tr_td2 = $D.g_ID(de.getId_valpag()).getParent();
            } catch (e) {
                tr_td2 = $D.g_ID(de.getId_valpag()).parentNode;
            }
            if (a.getVa_pagreg() != null)
                de.setVa_pagreg(a.getVa_pagreg());
            if (a.getTx_pagreg() != null)
                de.setTx_pagreg(a.getTx_pagreg());

            var m_input = $D.n_E('input', null, 'TEXT', de.getTx_pagreg(), null, (de.getIl_guareg()) ? 'input2 q s' : 'input2 q', de.getId_valpag(), '', null, 'if(event.keyCode==13) event.keyCode=9;');
            m_input.setAttribute("size", $D.g_ID(de.getId_valpag()).getAttribute("size"));
            m_input.setAttribute("valpag", de.getVa_pagreg());
            m_input.setAttribute("maxlength", $D.g_ID(de.getId_valpag()).getAttribute("maxlength"));

            tr_td2.innerHTML = "";
            tr_td2.appendChild(m_input);

        } else if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'O') & a.getTi_estreg() == 'L') {
            var tr_td2;
            try {
                tr_td2 = $D.g_ID(de.getId_valpag()).getParent();
            } catch (e) {
                tr_td2 = $D.g_ID(de.getId_valpag()).parentNode;
            }
            if (a.getVa_pagreg() != null)
                de.setVa_pagreg(a.getVa_pagreg());
            if (a.getTx_pagreg() != null)
                de.setTx_pagreg(a.getTx_pagreg());

            var m_label = $D.n_E('label', null, null, null, de.getTx_pagreg(), (de.getIl_guareg()) ? 'q s' : 'q', de.getId_valpag(), '', 'height: 16px', null);
            m_label.setAttribute("size", de.getCa_carcol());
            m_label.setAttribute("valpag", de.getVa_pagreg());
            m_label.setAttribute("maxlength", de.getCa_carcol());

            tr_td2.innerHTML = "";
            tr_td2.appendChild(m_label);

        } else if ((de.getTi_estreg() == 'E' | de.getTi_estreg() == 'L') & a.getTi_estreg() == 'O') {
            var tr_td1 = $D.g_ID("tr_td1_" + de.getId_valpag()).innerHTML = a.getNo_pagreg();//<====NO_PAGREG
            var tr_f = $D.g_ID("tr_" + de.getId_valpag());
            tr_f.setAttribute('style', "display:none");

            var tr_td2 = $D.g_ID("tr_td2_" + de.getId_valpag());//el td donde estan los componentes

            try {
                if (a.getVa_pagreg().length >= 0)
                    de.setVa_pagreg(a.getVa_pagreg());
            } catch (e) {
                de.setVa_pagreg(a.getVa_pagreg());
            }
            try {
                if (a.getTx_pagreg().length >= 0)
                    de.setTx_pagreg(a.getTx_pagreg());
            } catch (e) {
                de.setTx_pagreg(a.getTx_pagreg());
            }

            var m_label = $D.n_E('label', de.getVa_pagreg(), null, null, de.getTx_pagreg(), 'iqaro oculto', de.getId_valpag(), '', 'height: 16px', null);

            tr_td2.innerHTML = "";
            tr_td2.appendChild(m_label);
        } else if ((de.getTi_estreg() == 'E') & (a.getTi_estreg() == 'E')) {
            var tr_td2;
            try {
                tr_td2 = $D.g_ID(de.getId_valpag()).getParent();
            } catch (e) {
                tr_td2 = $D.g_ID(de.getId_valpag()).parentNode;
            }
            try {
                if (a.getVa_pagreg().length >= 0)
                    de.setVa_pagreg(a.getVa_pagreg());
            } catch (e) {
                de.setVa_pagreg(a.getVa_pagreg());
            }
            try {
                if (a.getTx_pagreg().length >= 0)
                    de.setTx_pagreg(a.getTx_pagreg());
            } catch (e) {
                de.setTx_pagreg(a.getTx_pagreg());
            }
            var m_input = $D.g_ID(de.getId_valpag());
            m_input.value = de.getTx_pagreg();
            m_input.setAttribute("name", de.getVa_pagreg());
        } else if ((de.getTi_estreg() == 'L') & (a.getTi_estreg() == 'L')) {
            console.log("aqui");
            //var tr_td = $D.g_ID("tr_td1_"+de.getId_valpag()).innerHTML = a.getNo_pagreg();//<====NO_PAGREG
            try {
                if (a.getVa_pagreg().length >= 0)
                    de.setVa_pagreg(a.getVa_pagreg());
            } catch (e) {
                de.setVa_pagreg(a.getVa_pagreg());
            }
            try {
                if (a.getTx_pagreg().length >= 0)
                    de.setTx_pagreg(a.getTx_pagreg());
            } catch (e) {
                de.setTx_pagreg(a.getTx_pagreg());
            }

            //var componente = null;

            //var m_label = TR.getElementById(de.getId_valpag());
            var m_label = null;

            try {
                var li = getElementsByClassName(TR, "q");
                for (var i = 0; i < li.length; i++) {
                    if (li[i].id == de.getId_valpag()) {
                        m_label = li[i];
                        i = li.length;
                    }
                }
                //componente = TR.getElementById(""+valpag_a.getCo_pagreg());
            } catch (e) {
                console.log(e);
            }

            console.log("m_label::" + m_label + "::" + m_label.id);
            //var m_label = $D.g_ID(de.getId_valpag());
            m_label.setAttribute('name', a.getVa_pagreg());
            m_label.innerHTML = a.getVa_pagreg();

        } else if ((de.getTi_estreg() == 'O') & (a.getTi_estreg() == 'O')) {
            var tr_td = $D.g_ID("tr_td1_" + de.getId_valpag()).innerHTML = a.getNo_pagreg();//<====NO_PAGREG
            try {
                if (a.getVa_pagreg().length >= 0)
                    de.setVa_pagreg(a.getVa_pagreg());
            } catch (e) {
                de.setVa_pagreg(a.getVa_pagreg());
            }
            try {
                if (a.getTx_pagreg().length >= 0)
                    de.setTx_pagreg(a.getTx_pagreg());
            } catch (e) {
                de.setTx_pagreg(a.getTx_pagreg());
            }
            var m_label = $D.g_ID(de.getId_valpag());
            m_label.setAttribute('name', a.getVa_pagreg());
            m_label.innerHTML = a.getTx_pagreg();
        }
        return false;
    } else if (de.getTi_pagreg() == 3 & a.getTi_pagreg() == 3) {
        var tr_td2 = $D.g_ID(de.getId_valpag()).getParent();
        var componente = $D.g_ID(de.getId_valpag());

        componente.removeAttribute("onchange");
        var c_js_o = $D.getJSON(url);
        var coincidencia = false;
        if (!isError(c_js_o)) {
            componente.innerHTML = "";
            var optn_b = $D.n_E("OPTION");
            componente.options.add(optn_b);
            for (var ic2 = 0; ic2 < c_js_o.length; ic2++) {
                var optn = $D.n_E("OPTION");
                optn.text = c_js_o[ic2].no_compag;
                if (a.getVa_pagreg() == c_js_o[ic2].co_compag) {
                    optn.selected = "selected";
                    coincidencia = true;
                }
                optn.value = c_js_o[ic2].co_compag;
                componente.options.add(optn);
            }
            componente.setAttribute("onchange", onchange);
            if (a.getTi_estreg() == 'L')
                componente.setAttribute("disabled", "disabled");
        } else {
            throw c_js_o;
        }
        return coincidencia;
    } else if (de.getTi_pagreg() == 4 & a.getTi_pagreg() == 4) {
        var tr_td2 = $D.g_ID(de.getId_valpag()).getParent();
        var componente = $D.g_ID(de.getId_valpag());
        componente.removeAttribute("onchange");
        var c_js_o = $D.getJSON(url);
        var coincidencia = false;
        if (!isError(c_js_o)) {
            componente.innerHTML = "";
            for (var ic2 = 0; ic2 < c_js_o.length; ic2++) {
                var optn = $D.n_E("OPTION");
                optn.text = c_js_o[ic2].no_compag;
                if (a.getVa_pagreg() == c_js_o[ic2].co_compag) {
                    optn.selected = "selected";
                    coincidencia = true;
                }
                optn.value = c_js_o[ic2].co_compag;
                componente.options.add(optn);
            }
            componente.setAttribute("onchange", onchange);
            if (a.getTi_estreg() == 'L')
                componente.setAttribute("disabled", "disabled");
        } else {
            throw c_js_o;
        }
        return coincidencia;
    } else if (de.getTi_pagreg() == 5 & a.getTi_pagreg() == 5) {
        var tr_td2 = $D.g_ID(de.getId_valpag()).getParent();

        var componente = $D.g_ID(de.getId_valpag());
        var c_js_o = $D.getJSON(url);
        var coincidencia = false;
        if (!isError(c_js_o)) {
            var va_val = $D.g_ID(de.getId_valpag());//input hidden
            var val_onchange = va_val.getAttribute("onchange");
            var m_tabla = $D.n_E("table", null, null, null, null, null, de.getId_valpag() + "_table_radio", null, 'padding: 0px; margin: 0px;');
            m_tabla.setAttribute("width", "100%");
            m_tabla.setAttribute("cellpadding", "0");
            m_tabla.setAttribute("cellspacing", "0");
            var m_tr = $D.n_E("tr", null, null, null, null, null, de.getId_valpag() + "_tr", null, 'padding: 0px; margin: 0px; height: 16px;');
            m_tabla.appendChild(m_tr);

            var coincidencia = false;
            if (!(a.length > 0))
                de.setVa_pagreg(a.getVa_pagreg());
            for (var ic2 = 0; ic2 < c_js_o.length; ic2++) {
                var n_td_1 = $D.n_E("td", null, null, null, null, 'input2', null, null, 'border-width: 0px; margin: 0px; padding: 0px; height: 16px;');
                n_td_1.width = "2%";

                var n_rd = $D.n_E("input", va_val.getAttribute("id"), 'radio', c_js_o[ic2].co_compag, null, 'input2', de.getId_valpag() + "_" + ic2, 'L', 'padding: 0px; margin: 0px 0px 0px 0px; height: 12px;', null, "actualizaradio(this,'" + de.getId_valpag() + "')");
                if (a.getTi_estreg() == 'L')
                    n_rd.setAttribute("disabled", "disabled");
                if (de.getVa_pagreg() == c_js_o[ic2].co_compag) {
                    n_rd.checked = "true";
                    coincidencia = true;
                }

                n_td_1.appendChild(n_rd);//agregando el radio al primer td
                m_tr.appendChild(n_td_1);//agregando el primer td al tr

                var n_td_2 = $D.n_E("td", null, null, null, null, 'tdPagina4', null, null, 'border-color: white; padding: 1px 4px 0px 1px;');
                var n_lb = $D.n_E("label", null, null, null, c_js_o[ic2].no_compag, null, de.getId_valpag() + "_" + ic2 + "_l");
                n_lb.setAttribute("for", de.getId_valpag() + "_" + ic2);
                n_td_2.appendChild(n_lb);//agregando el label al segundo td
                m_tr.appendChild(n_td_2);//agregando el segundo td al tr
            }
            //<input  onchange="valpag_pos(this,'${paginaBean.reg.id.co_pagreg}','${p.id.co_pagina}','${r}');"/>
            var m_input = $D.n_E("input", null, 'hidden', de.getVa_pagreg(), null, 'iqaro radio', de.getId_valpag(), null, null, null, val_onchange);
            tr_td2.innerHTML = "";
            tr_td2.appendChild(m_tabla);
            tr_td2.appendChild(m_input);
        } else {
            throw c_js_o;
        }
        return coincidencia;
    }
}

function actualiza_componente_tr(de, a, onchange, url, L) {
    if (de.getTi_pagreg() == 1 & (a.getTi_pagreg() == 3 | a.getTi_pagreg() == 4)) {//de texto a combo
        var tr_td1 = $D.g_ID("tr_td1_" + de.getId_valpag()).innerHTML = a.getNo_pagreg();//<====NO_PAGREG
        var tr_td = $D.g_ID("tr_td2_" + de.getId_valpag());//el td donde estan los componentes

        var m_select = $D.n_E("SELECT", null, null, null, null, (a.getTi_pagreg() == 3) ? 'input2 iqaro combo' : 'input2 iqaro combo2', de.getId_valpag(), L);//creo al combo
        if (a.getTi_estreg() == 'L')
            m_select.setAttribute("disabled", "disabled");
        if (de.getTi_estreg() == 'O') {
            var tr_f = $D.g_ID("tr_" + de.getId_valpag());
            tr_f.removeAttribute('style');
        }

        var c_js_o = $D.getJSON(url);//consigo
        if (a.getTi_pagreg() == 3) {
            var optn_b = $D.n_E("OPTION");
            m_select.options.add(optn_b);
        }
        var coincidencia = false;
        if (!(trim(a.getVa_pagreg()).length > 0))
            de.setVa_pagreg(a.getVa_pagreg())
        for (var ic2 = 0; ic2 < c_js_o.length; ic2++) {
            var optn = $D.n_E("OPTION");
            optn.text = c_js_o[ic2].no_compag;
            if (de.getVa_pagreg() == c_js_o[ic2].co_compag) {
                optn.selected = "selected";
                coincidencia = true;
            }
            optn.value = c_js_o[ic2].co_compag;
            m_select.options.add(optn);
        }
        m_select.setAttribute("onchange", onchange);

        tr_td.innerHTML = "";
        tr_td.appendChild(m_select);

        return coincidencia;
    } else if (de.getTi_pagreg() == 1 & a.getTi_pagreg() == 5) {//de texto a radiobutton
        var tr_td1 = $D.g_ID("tr_td1_" + de.getId_valpag()).innerHTML = a.getNo_pagreg();//<====NO_PAGREG    
        var tr_td = $D.g_ID("tr_td2_" + de.getId_valpag());//el td donde estan los componentes    

        var va_val = $D.g_ID(de.getId_valpag());//input hidden
        var val_onchange = va_val.getAttribute("onchange");

        var c_js_o = $D.getJSON(url);

        var m_tabla = $D.n_E("table", null, null, null, null, null, de.getId_valpag() + "_table_radio", null, 'padding: 0px; margin: 0px;');
        m_tabla.setAttribute("width", "100%");
        m_tabla.setAttribute("cellpadding", "0");
        m_tabla.setAttribute("cellspacing", "0");

        var m_tr = $D.n_E("tr", null, null, null, null, null, de.getId_valpag() + "_tr", null, 'padding: 0px; margin: 0px; height: 16px;');
        m_tabla.appendChild(m_tr);

        var coincidencia = false;
        if (!(a.length > 0))
            de.setVa_pagreg(a.getVa_pagreg())
        for (var ic2 = 0; ic2 < c_js_o.length; ic2++) {

            var n_td_1 = $D.n_E("td", null, null, null, null, 'input2', null, null, 'border-width: 0px; margin: 0px; padding: 0px; height: 16px;');
            n_td_1.width = "2%";

            var n_rd = $D.n_E("input", va_val.getAttribute("id"), 'radio', c_js_o[ic2].co_compag, null, 'input2', de.getId_valpag() + "_" + ic2, L, 'padding: 0px; margin: 0px 0px 0px 0px; height: 12px;', null, "actualizaradio(this,'" + de.getId_valpag() + "')");
            if (a.getTi_estreg() == 'L')
                n_rd.setAttribute("disabled", "disabled");
            if (de.getVa_pagreg() == c_js_o[ic2].co_compag) {
                n_rd.checked = "true";
                coincidencia = true;
            }

            n_td_1.appendChild(n_rd);//agregando el radio al primer td
            m_tr.appendChild(n_td_1);//agregando el primer td al tr

            var n_td_2 = $D.n_E("td", null, null, null, null, 'tdPagina4', null, null, 'border-color: white; padding: 1px 4px 0px 1px;');

            var n_lb = $D.n_E("label", null, null, null, c_js_o[ic2].no_compag, null, de.getId_valpag() + "_" + ic2 + "_l");
            n_lb.setAttribute("for", de.getId_valpag() + "_" + ic2);
            n_td_2.appendChild(n_lb);//agregando el label al segundo td
            m_tr.appendChild(n_td_2);//agregando el segundo td al tr
        }
        var m_input = $D.n_E("input", null, 'hidden', de.getVa_pagreg(), null, 'iqaro radio', de.getId_valpag(), null, null, null, val_onchange);
        tr_td.innerHTML = "";
        tr_td.appendChild(m_tabla);
        tr_td.appendChild(m_input);

    } else if (de.getTi_pagreg() == 1 & a.getTi_pagreg() == 7) {//de texto a combo
        var tr_td1 = $D.g_ID("tr_td1_" + de.getId_valpag()).innerHTML = a.getNo_pagreg();//<====NO_PAGREG
        if (de.getTi_estreg() == 'O') {
            var tr_f = $D.g_ID("tr_" + de.getId_valpag());
            tr_f.removeAttribute('style');
        }
        var tr_td = $D.g_ID("tr_td2_" + de.getId_valpag());//el td donde estan los componentes

        var va_val = $D.g_ID(de.getId_valpag());//input hidden

        var m_tabla = $D.n_E("table", null, null, null, null, null, "tr_td2_" + de.getId_valpag() + "_table_fecha", ull, 'padding: 0px; margin: 0px; border: 0px;');
        m_tabla.setAttribute("cellspacing", "0px");
        m_tabla.setAttribute("cellpadding", "0px");
        var m_tr = $D.n_E("tr");
        m_tabla.appendChild(m_tr);

        var m_td1 = $D.n_E("td", null, null, null, null, 'tdPagina4', null, null, 'padding: 0px; margin: 0px; height: 16px;width: 20px; border-width: 0px; border-style: solid;');
        var m_input1 = $D.n_E("input", "ff_dia" + de.getId_valpag().replace("va_regist_", ""), 'text', null, null, null, "ff_dia" + de.getId_valpag().replace("va_regist_", ""), null, 'width: 25px;', null, "texto_fecha('" + de.getId_valpag().replace("va_regist_", "") + "');");
        m_input1.setAttribute("onkeypress", "nn_Key()");
        m_input1.setAttribute("onkeyup", "nn_Key();texto_fecha('" + de.getId_valpag().replace("va_regist_", "") + "');");
        m_input1.setAttribute("maxlength", "2");
        m_input1.setAttribute("size", "1");
        try {
            if (a.getVa_pagreg().length > 0) {
                m_input1.setAttribute("value", a.getVa_pagreg().substring(8, 10));
            }
            else
                m_input1.setAttribute("value", de.getVa_pagreg().substring(8, 10));
        } catch (e) {
            m_input1.setAttribute("value", de.getVa_pagreg().substring(8, 10));
        }
        if (a.getTi_estreg() == 'L')
            m_input1.setAttribute("readonly", "readonly");
        m_input1.className = "input2";
        m_td1.appendChild(m_input1);

        m_tr.appendChild(m_td1);//agregado el primer td

        var m_td2 = $D.n_E("td", null, null, null, "/", 'tdPagina4', null, null, 'padding: 0px 2px 0px 2px; margin: 0px; height: 14px; border-width: 0px; border-style: solid;');
        m_tr.appendChild(m_td2);//agregado el primer td

        var m_td3 = $D.n_E("td", null, null, null, "/", 'tdPagina4', null, null, 'padding: 0px; margin: 0px; height: 16px;width: 20px; border-width: 0px; border-style: solid;');

        var m_input2 = $D.n_E("input", "ff_mes" + de.getId_valpag().replace("va_regist_", ""), 'text', null, null, 'input2', "ff_mes" + de.getId_valpag().replace("va_regist_", ""), null, 'width: 25px;', null, "texto_fecha('" + de.getId_valpag().replace("va_regist_", "") + "');");
        m_input2.setAttribute("onkeypress", "nn_Key()");
        m_input2.setAttribute("onkeyup", "nn_Key();texto_fecha('" + de.getId_valpag().replace("va_regist_", "") + "');");
        m_input2.setAttribute("maxlength", "2");
        m_input2.setAttribute("size", "1");
        try {
            if (a.getVa_pagreg().length > 0) {
                m_input2.setAttribute("value", a.getVa_pagreg().substring(5, 7));
            }
            else
                m_input2.setAttribute("value", de.getVa_pagreg().substring(5, 7));
        } catch (e) {
            m_input2.setAttribute("value", de.getVa_pagreg().substring(5, 7));
        }
        if (a.getTi_estreg() == 'L')
            m_input2.setAttribute("readonly", "readonly");
        m_td3.appendChild(m_input2);


        m_tr.appendChild(m_td3);//agregado el segundo td

        var m_td4 = $D.n_E("td", null, null, null, null, 'tdPagina4', null, null, 'padding: 0px 2px 0px 2px; margin: 0px; height: 14px; border-width: 0px; border-style: solid;');
        m_tr.appendChild(m_td4);//agregado el primer td

        var m_td5 = $D.n_E("td", null, null, null, 'tdPagina4', null, null, "padding: 0px; margin: 0px; height: 16px;width: 20px; border-width: 0px; border-style: solid;");

        var m_input3 = $D.n_E("input", "ff_anio" + de.getId_valpag().replace("va_regist_", ""), 'text', null, null, 'input2', "ff_anio" + de.getId_valpag().replace("va_regist_", ""), null, 'width: 40px;', null, "texto_fecha('" + de.getId_valpag().replace("va_regist_", "") + "');");
        m_input3.setAttribute("onkeypress", "nn_Key()");
        m_input3.setAttribute("onkeyup", "nn_Key();texto_fecha('" + de.getId_valpag().replace("va_regist_", "") + "');");
        m_input3.setAttribute("maxlength", "4");
        m_input3.setAttribute("size", "4");
        try {
            if (a.getVa_pagreg().length > 0) {
                m_input3.setAttribute("value", a.getVa_pagreg().substring(0, 4));
            }
            else
                m_input3.setAttribute("value", de.getVa_pagreg().substring(0, 4));
        } catch (e) {
            m_input3.setAttribute("value", de.getVa_pagreg().substring(0, 4));
        }
        if (a.getTi_estreg() == 'L')
            m_input3.setAttribute("readonly", "readonly");
        m_td5.appendChild(m_input3);

        m_tr.appendChild(m_td5);//agregado el tercer td


        var m_td6 = $D.n_E("td");
        if (a.getTi_estreg() == 'L')
            m_td6.setAttribute("style", "padding: 0px 2px 0px 2px; margin: 0px; height: 14px; border-width: 0px; border-style: solid;display:none;");
        else
            m_td6.setAttribute("style", "padding: 0px 2px 0px 2px; margin: 0px; height: 14px; border-width: 0px; border-style: solid;");
        m_td6.className = "tdPagina4";

        var m_input4 = $D.n_E("input", "va_regist_" + de.getId_valpag().replace("va_regist_", ""), 'hidden', null, null, 'q f', "va_regist_" + de.getId_valpag().replace("va_regist_", "").L, 'width: 40px;', null, "cambio(this,'" + de.getId_valpag().replace("va_regist_", "") + "');");
        try {
            if (a.getVa_pagreg().length > 0) {
                m_input4.setAttribute("value", a.getVa_pagreg());
            }
            else
                m_input4.setAttribute("value", de.getVa_pagreg());
        } catch (e) {
            m_input4.setAttribute("value", de.getVa_pagreg());
        }
        m_td6.appendChild(m_input4);

        var m_img = $D.n_E("img", null, null, null, null, null, '"trigger"+de.getId_valpag().replace("va_regist_", "")', null, 'cursor: pointer; border: 1px solid #073362;');
        m_img.setAttribute("align", "middle");
        m_img.setAttribute("src", "../js/jscalendar-1.0/img.gif");
        m_img.setAttribute("title", "Seleccione Fecha");
        m_img.setAttribute("onmouseover", "this.style.background='#073362';");
        m_img.setAttribute("onmouseout", "this.style.background=''");
        m_td6.appendChild(m_img);

        m_tr.appendChild(m_td6);//removiendo al co_pag
        var m_td7 = $D.n_E("td", null, null, '(dd/mm/yyyy)', 'tdPagina4', null, null, "padding: 0px 2px 0px 2px; margin: 0px; height: 14px; border-width: 0px; border-style: solid;");
        m_tr.appendChild(m_td7);

        tr_td.removeChild(va_val);//removiendo al co_pag
        tr_td.appendChild(m_tabla);
        try {
            eval("fechas[fe]='" + de.getId_valpag().replace("va_regist_", "") + "';Calendar.setup({inputField     :    'va_regist_'+fechas[fe],ifFormat       :    '%Y-%m-%d', button         :    'trigger'+fechas[fe],  align          :    'cc',singleClick    :    true});fe++;$D.g_ID('va_regist_" + de.getId_valpag().replace("va_regist_", "") + "').onchange();")
        } catch (e) {
        }

    } else if ((de.getTi_pagreg() == 3 | de.getTi_pagreg() == 4) & a.getTi_pagreg() == 1) {
        var tr_td1 = $D.g_ID("tr_td1_" + de.getId_valpag()).innerHTML = a.getNo_pagreg();//<====NO_PAGREG
        var tr_td = $D.g_ID("tr_td2_" + de.getId_valpag());//el td donde estan los componentes

        var va_val = $D.g_ID(de.getId_valpag());//en este caso un combo

        if (a.getTi_estreg() == 'L') {
            var m_label = $D.n_E("label", null, null, null, null, 'iqaro', null, L, 'height: 16px', null, onchange);
            m_label.setAttribute("id", de.getId_valpag());
            try {
                m_label.setAttribute("name", '' + a.getVa_pagreg());
            } catch (e) {
                m_label.setAttribute("name", '' + de.getVa_pagreg());
            }
            try {
                m_label.innerHTML = a.getTx_pagreg();
            } catch (e) {
                m_label.innerHTML = de.getTx_pagreg();
            }

            tr_td.appendChild(m_label);
        } else if (a.getTi_estreg() == 'E') {
            var m_input = $D.n_E("input", null, 'text', null, null, 'iqaro input2', de.getId_valpag(), L, null, 'if(event.keyCode==13) event.keyCode=9;');
            try {
                m_input.setAttribute("name", a.getVa_pagreg());
            } catch (e) {
                m_input.setAttribute("name", de.getVa_pagreg());
            }
            try {
                m_input.setAttribute("value", a.getTx_pagreg());
            } catch (e) {
                m_input.setAttribute("value", de.getTx_pagreg());
            }
            tr_td.appendChild(m_input);
        } else if (a.getTi_estreg() == 'O') {
            var tr_f = $D.g_ID("tr_" + de.getId_valpag());
            tr_f.setAttribute('style', "display:none");
            var m_label = $D.n_E("label", null, null, null, null, 'iqaro oculto', de.getId_valpag(), L, 'height: 16px', null, onchange);
            try {
                if (a.getVa_pagreg().length > 0)
                    m_label.setAttribute("name", a.getVa_pagreg());
                else
                    m_label.setAttribute("name", de.getVa_pagreg());
            } catch (e) {
                m_label.setAttribute("name", de.getVa_pagreg());
            }
            try {
                m_label.innerHTML = a.getTx_pagreg();
            } catch (e) {
                m_label.innerHTML = de.getTx_pagreg();
            }
            tr_td.appendChild(m_label);
        }
        tr_td.removeChild(va_val);
    } else if (de.getTi_pagreg() == 5 & a.getTi_pagreg() == 1) {
        var tr_td1 = $D.g_ID("tr_td1_" + de.getId_valpag()).innerHTML = a.getNo_pagreg();//<====NO_PAGREG
        var tr_td = $D.g_ID("tr_td2_" + de.getId_valpag());//el td donde estan los componentes
        var va_val = $D.g_ID(de.getId_valpag());//en este caso un radio button
        var val_onchange = va_val.getAttribute("onchange");
        var aremov = $D.g_ID(de.getId_valpag() + "_table_radio");
        tr_td.removeChild(aremov);
        tr_td.removeChild(va_val);
        if (a.getTi_estreg() == 'L') {
            var m_label = $D.n_E("label", null, null, null, null, 'iqaro', de.getId_valpag(), L, 'height: 16px', null, val_onchange);
            try {
                m_label.setAttribute("name", a.getVa_pagreg());
            } catch (e) {
                m_label.setAttribute("name", de.getVa_pagreg());
            }
            try {
                m_label.innerHTML = a.getTx_pagreg();
            } catch (e) {
                m_label.innerHTML = de.getTx_pagreg();
            }
            tr_td.appendChild(m_label);
        } else if (a.getTi_estreg() == 'E') {
            var m_input = $D.n_E("input");
            m_input.setAttribute("type", "text");
            m_input.setAttribute("id", de.getId_valpag());
            try {
                m_input.setAttribute("name", a.getVa_pagreg());
            } catch (e) {
                m_input.setAttribute("name", de.getVa_pagreg());
            }

            m_input.className = "iqaro input2";
            m_input.setAttribute("onkeydown", "if(event.keyCode==13) event.keyCode=9;");
            m_input.setAttribute("form", L);

            try {
                m_input.value = a.getTx_pagreg();
            } catch (e) {
                m_input.setAttribute("value", de.getTx_pagreg());
            }
            m_input.setAttribute("onchange", val_onchange);
            tr_td.appendChild(m_input);
        }

    } else if (de.getTi_pagreg() == 7 & a.getTi_pagreg() == 1) {
        var tr_td1 = $D.g_ID("tr_td1_" + de.getId_valpag()).innerHTML = a.getNo_pagreg();//<====NO_PAGREG
        var tr_td = $D.g_ID("tr_td2_" + de.getId_valpag());//el td donde estan los componentes

        var va_val = $D.g_ID(de.getId_valpag());
        tr_td.innerHTML = "";

        if (a.getTi_estreg() == 'L') {
            var m_label = $D.n_E("label", null, null, null, null, 'iqaro', de.getId_valpag(), L, "height: 16px");
            try {
                if (a.getVa_pagreg().length > 0)
                    m_label.setAttribute("name", a.getVa_pagreg());
                else
                    m_label.setAttribute("name", de.getVa_pagreg());
            } catch (e) {
                m_label.setAttribute("name", de.getVa_pagreg());
            }
            try {
                if (a.getVa_pagreg().length > 0)
                    m_label.innerHTML = a.getTx_pagreg();
                else
                    m_label.innerHTML = de.getTx_pagreg();
            } catch (e) {
                m_label.innerHTML = de.getTx_pagreg();
            }
        } else if (a.getTi_estreg() == 'E') {
            var m_input = $D.n_E("input", null, 'text', null, null, 'iqaro input2', de.getId_valpag(), L, null, 'if(event.keyCode==13) event.keyCode=9;', null);
            try {
                if (a.getVa_pagreg().length > 0)
                    m_input.setAttribute("name", a.getVa_pagreg());
                else
                    m_input.setAttribute("name", de.getVa_pagreg());
            } catch (e) {
                m_input.setAttribute("name", de.getVa_pagreg());
            }
            try {
                if (a.getVa_pagreg().length > 0)
                    m_input.setAttribute("value", a.getTx_pagreg());
                else
                    m_input.setAttribute("value", de.getTx_pagreg());
            } catch (e) {
                m_input.setAttribute("value", de.getTx_pagreg());
            }
            tr_td.appendChild(m_input);
        } else if (a.getTi_estreg() == 'O') {
            var tr_f = $D.g_ID("tr_" + de.getId_valpag(), null, null, null, null, null, null, null, 'display:none');
            var m_label = $D.n_E("label", null, null, null, null, 'iqaro oculto', de.getId_valpag(), L);
            try {
                if (a.getVa_pagreg().length > 0)
                    m_label.setAttribute("name", a.getVa_pagreg());
                else
                    m_label.setAttribute("name", de.getVa_pagreg());
            } catch (e) {
                m_label.setAttribute("name", de.getVa_pagreg());
            }
            try {
                if (a.getVa_pagreg().length > 0)
                    m_label.innerHTML = a.getTx_pagreg();
                else
                    m_label.innerHTML = de.getTx_pagreg();
            } catch (e) {
                m_label.innerHTML = de.getTx_pagreg();
            }
            tr_td.appendChild(m_label);
        }

    } else if (de.getTi_pagreg() == 4 & a.getTi_pagreg() == 3) {
        var tr_td = $D.g_ID("tr_td1_" + de.getId_valpag()).innerHTML = a.getNo_pagreg();//<====NO_PAGREG
        var componente = $D.g_ID(de.getId_valpag());
        componente.removeAttribute("onchange");
        var c_js_o = $D.getJSON(url);
        componente.innerHTML = "";

        var optn_b = $D.n_E("OPTION");
        componente.options.add(optn_b);
        var coincidencia = false;
        for (var ic2 = 0; ic2 < c_js_o.length; ic2++) {
            var optn = $D.n_E("OPTION");
            optn.text = c_js_o[ic2].no_compag;
            if (a.getVa_pagreg() == c_js_o[ic2].co_compag) {
                optn.selected = "selected";
                coincidencia = true;
            }
            optn.value = c_js_o[ic2].co_compag;
            componente.options.add(optn);
        }
        componente.setAttribute("onchange", onchange);
        if (a.getTi_estreg() == 'L')
            componente.setAttribute("disabled", "disabled");
    } else if (de.getTi_pagreg() == 3 & a.getTi_pagreg() == 4) {
        var tr_td = $D.g_ID("tr_td1_" + de.getId_valpag()).innerHTML = a.getNo_pagreg();//<====NO_PAGREG
        var componente = $D.g_ID(de.getId_valpag());
        componente.removeAttribute("onchange");
        var c_js_o = $D.getJSON(url);
        componente.innerHTML = "";

        var coincidencia = false;
        for (var ic2 = 0; ic2 < c_js_o.length; ic2++) {
            var optn = $D.n_E("OPTION");
            optn.text = c_js_o[ic2].no_compag;
            if (a.getVa_pagreg() == c_js_o[ic2].co_compag) {
                optn.selected = "selected";
                coincidencia = true;
            }
            optn.value = c_js_o[ic2].co_compag;
            componente.options.add(optn);
        }
        componente.setAttribute("onchange", onchange);
        if (a.getTi_estreg() == 'L')
            componente.setAttribute("disabled", "disabled");
    }

}
